HttpResponse.ClearHeaders 方法

定義

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

C#
public void ClearHeaders ();

例外狀況

標頭在 HTTP 標頭送出之後被清除。

範例

下列範例會 ClearHeaders 呼叫 方法,以確保沒有使用目前回應傳送標頭。 如果 ASP.NET 回應產生影像,例如 JPEG 檔案,這項技術特別重要。 在此範例中, ContentType 屬性會設定為 image/jpeg。

C#
// Clear headers to ensure none
// are sent to the requesting browser
// and set the content type.
Response.ClearHeaders();
Response.ContentType = "image/jpeg";

適用於

產品 版本
.NET Framework 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8

另請參閱