Response Property
Collapse the table of content
Expand the table of content

WebException.Response Property

 

Gets the response that the remote host returned.

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

member Response : WebResponse with get

Property Value

Type: System.Net.WebResponse

If a response is available from the Internet resource, a WebResponse instance that contains the error response from an Internet resource; otherwise, null.

Some Internet protocols, such as HTTP, return otherwise valid responses indicating that an error has occurred at the protocol level. When the response to an Internet request indicates an error, WebRequest.GetResponse sets the Status property to WebExceptionStatus.ProtocolError and provides the WebResponse that contains the error message in the Response property of the WebException that was thrown. The application can examine the WebResponse to determine the actual error.

The following example checks the Status property and prints to the console the StatusCode and StatusDescription of the underlying HttpWebResponse instance.

No code example is currently available or this language may not be supported.

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