HttpResponse.ClearHeaders 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
清除緩衝區串流中的所有標頭。
public:
void ClearHeaders();
public void ClearHeaders();
member this.ClearHeaders : unit -> unit
Public Sub ClearHeaders ()
例外狀況
標頭在 HTTP 標頭傳送後才會被清除。
範例
以下範例會呼叫該 ClearHeaders 方法,以確保目前回應中沒有標頭被傳送。 當 ASP.NET 回應產生影像(如 JPEG 檔案)時,這項技術尤其重要。 在這個例子中,屬性 ContentType 設定為 image/jpeg。
// Clear headers to ensure none
// are sent to the requesting browser
// and set the content type.
Response.ClearHeaders();
Response.ContentType = "image/jpeg";
' Clear headers to ensure none
' are sent to the requesting browser
' and set the content type.
Response.ClearHeaders()
Response.ContentType = "image/jpeg"