HttpResponse.ContentType 属性

定义

获取或设置输出流的 HTTP MIME 类型。

public:
 property System::String ^ ContentType { System::String ^ get(); void set(System::String ^ value); };
public string ContentType { get; set; }
member this.ContentType : string with get, set
Public Property ContentType As String

属性值

String

输出流的 HTTP MIME 类型。 默认值为“text/html”。

例外

ContentType 属性设置为 null

示例

以下示例设置 ContentType 对 image/jpeg 的响应的属性,调用 Clear 该方法删除可能附加到响应的其他内容,然后将该属性设置为 BufferOutput true,以便在将任何内容发送到请求客户端之前处理完整页面。

有关完整示例,请参阅 HttpResponse 该类。

    // Set the page's content type to JPEG files
    // and clears all content output from the buffer stream.
    Response.ContentType = "image/jpeg";
    Response.Clear();

    // Buffer response so that page is sent
    // after processing is complete.
    Response.BufferOutput = true;
' Set the page's content type to JPEG files
' and clears all content output from the buffer stream.
Response.ContentType = "image/jpeg"
Response.Clear()

' Buffer response so that page is sent
' after processing is complete.
Response.BufferOutput = True

适用于