This documentation is archived and is not being maintained.

HttpListenerResponse.ContentType Property

Gets or sets the MIME type of the content returned.

Namespace: System.Net
Assembly: System (in system.dll)

'Declaration
Public Property ContentType As String
'Usage
Dim instance As HttpListenerResponse
Dim value As String

value = instance.ContentType

instance.ContentType = value
/** @property */
public String get_ContentType ()

/** @property */
public void set_ContentType (String value)

public function get ContentType () : String

public function set ContentType (value : String)

Not applicable.

Property Value

A String instance that contains the text of the response's Content-Type header.

Exception typeCondition

ArgumentNullException

The value specified for a set operation is a null reference (Nothing in Visual Basic).

ArgumentException

The value specified for a set operation is an empty string ("").

ObjectDisposedException

This object is closed.

When communicating with a Web browser, you should explicitly set this property when returning any content type other than text/html.

For a complete list of response headers, see the HttpResponseHeader enumeration.

Windows 98, Windows Server 2003, Windows XP Media Center Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0
Show: