共用方式為


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"

適用於

另請參閱