HttpResponse.ContentType Właściwość

Definicja

Pobiera lub ustawia typ HTTP MIME strumienia wyjściowego.

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

Wartość właściwości

String

Typ HTTP MIME strumienia wyjściowego. Wartość domyślna to "text/html".

Wyjątki

Właściwość ContentType ma ustawioną wartość null.

Przykłady

Poniższy przykład ustawia ContentType właściwość dla odpowiedzi na obraz/jpeg, wywołuje Clear metodę w celu usunięcia innej zawartości, która może być dołączona do odpowiedzi, a następnie ustawia BufferOutput właściwość na true, aby kompletna strona została przetworzona przed wysłaniem jakiejkolwiek zawartości do klienta żądającego.

Pełny przykład można znaleźć w HttpResponse klasie .

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

Dotyczy