HttpResponse.ClearHeaders HttpResponse.ClearHeaders HttpResponse.ClearHeaders HttpResponse.ClearHeaders Method

定义

清除缓冲区流中的所有头。Clears all headers from the buffer stream.

public:
 void ClearHeaders();
public void ClearHeaders ();
member this.ClearHeaders : unit -> unit
Public Sub ClearHeaders ()

异常

发送 HTTP 标头后清除标头。Headers are cleared after the HTTP headers have been sent.

示例

下面的示例调用ClearHeaders方法,以确保不会与当前响应一起发送任何标头。The following example calls the ClearHeaders method to ensure that no headers are sent with the current response. 如果 ASP.NET 响应正在生成图像(如 JPEG 文件),则此方法可能特别重要。This technique can be especially important if the ASP.NET response is generating an image, such as a JPEG file. 在此示例中ContentType ,将属性设置为 image/jpeg。In this example the ContentType property is set to 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"

适用于

另请参阅