HttpResponse.ContentType Egenskap
Definition
Viktigt
En del information gäller för förhandsversionen av en produkt och kan komma att ändras avsevärt innan produkten blir allmänt tillgänglig. Microsoft lämnar inga garantier, uttryckliga eller underförstådda, avseende informationen som visas här.
Hämtar eller anger HTTP MIME-typen för utdataströmmen.
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
Egenskapsvärde
HTTP MIME-typen för utdataströmmen. Standardvärdet är "text/html".
Undantag
Egenskapen ContentType är inställd på null.
Exempel
I följande exempel anges ContentType egenskapen för svaret på bild/jpeg, anropar Clear metoden för att ta bort annat innehåll som kan vara kopplat till svaret och anger BufferOutput sedan egenskapen till true så att hela sidan bearbetas innan innehåll skickas till den begärande klienten.
Ett fullständigt exempel finns i HttpResponse klassen .
// 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