Sdílet prostřednictvím


HttpResponse.ContentType Vlastnost

Definice

Získá nebo nastaví typ HTTP MIME výstupního datového proudu.

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

Hodnota vlastnosti

Typ HTTP MIME výstupního streamu. Výchozí hodnota je "text/html".

Výjimky

Vlastnost ContentType je nastavena na hodnotu null.

Příklady

Následující příklad nastaví ContentType vlastnost pro odpověď na image/jpeg, volá metodu Clear pro odebrání dalšího obsahu, který může být připojen k odpovědi, a potom nastaví BufferOutput vlastnost na true, aby byla kompletní stránka zpracována před odesláním jakéhokoli obsahu do žádajícího klienta.

Úplný příklad najdete v HttpResponse třídě.

    // 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

Platí pro