HttpResponse.ContentType Proprietà

Definizione

Ottiene o imposta il tipo MIME HTTP del flusso di output.

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

Valore della proprietà

Tipo MIME HTTP del flusso di output. Il valore predefinito è "text/html".

Eccezioni

La proprietà ContentType è impostata su null.

Esempio

L'esempio seguente imposta la ContentType proprietà per la risposta a image/jpeg, chiama il Clear metodo per rimuovere altri contenuti che potrebbero essere associati alla risposta e quindi imposta la BufferOutput proprietà su true in modo che la pagina completa venga elaborata prima dell'invio di qualsiasi contenuto al client richiedente.

Per un esempio completo, vedere la HttpResponse classe .

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

Si applica a