HttpResponse.ClearHeaders 方法

定義

從緩衝區資料流清除所有標頭。

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"

適用於

另請參閱