HttpResponse.ContentType Vlastnost

Definice

Získá nebo nastaví typ HTTP MIME výstupního streamu.

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, zavolá metodu Clear pro odebrání jiného obsahu, který může být připojen k odpovědi, a potom nastaví BufferOutput vlastnost na true, aby se před odesláním libovolného obsahu do žádajícího klienta zpracovala úplná stránka.

Úplný příklad najdete ve 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