HttpResponse.ContentType 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定輸出串流的 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
屬性值
輸出串流的 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