ContentType Property

WebResponse.ContentType Property


When overridden in a derived class, gets or sets the content type of the data being received.

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

Public Overridable Property ContentType As String

Property Value

Type: System.String

A string that contains the content type of the response.

Exception Condition

Any attempt is made to get or set the property, when the property is not overridden in a descendant class.

The ContentType property contains the MIME content type of the response from the Internet resource, if known.


The WebResponse class is an abstract class. The actual behavior of WebResponse instances at run time is determined by the descendant class returned by WebRequest.GetResponse. For more information about default values and exceptions, please see the documentation for the descendant classes, such as HttpWebResponse and FileWebResponse.

The following example uses the ContentType property to obtain the content type of the response.

Snippet section 1 of code snippet {"project_id":"3fedad16-eaf1-41a6-8f96-0c1949c68f32","entity_id":"dc65913b-26d3-4b84-ac67-ea6a636049c5","entity_type":"CodeSnippet","locale":"en-US"} in source file ({"filename":"/VB/webresponse_contentlength_type.vb","blob_type":"Source","blob_id":"-002fvb-002fwebresponse-005fcontentlength-005ftype-002evb","blob_revision":2}) overlaps with other snippet sections. Ensure the tags are placed correctly.

Universal Windows Platform
Available since 4.5
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top
© 2015 Microsoft