HttpResponse.ContentType Tulajdonság

Definíció

Lekéri vagy beállítja a kimeneti stream HTTP MIME-típusát.

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

Tulajdonság értéke

A kimeneti stream HTTP MIME-típusa. Az alapértelmezett érték a "text/html".

Kivételek

A ContentType tulajdonság be van állítva null-re.

Példák

Az alábbi példa beállítja a ContentType képre/jpegre adott válasz tulajdonságát, meghívja a Clear metódust, hogy távolítsa el a válaszhoz csatolható egyéb tartalmakat, majd igaz értékre állítja a BufferOutput tulajdonságot, hogy a teljes oldal feldolgozásra kerül, mielőtt bármilyen tartalmat elküldenének a kérelmező ügyfélnek.

A teljes példáért tekintse meg az osztályt 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

A következőre érvényes: