This documentation is archived and is not being maintained.

WebException::Status Property

Gets the status of the response.

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

property WebExceptionStatus Status {
	WebExceptionStatus get ();

Property Value

Type: System.Net::WebExceptionStatus
One of the WebExceptionStatus values.

The Status property indicates the reason for the WebException.

The value of Status is one of the WebExceptionStatus values.

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

   // Create a web request for an unknown server (this raises the WebException).
   HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)(WebRequest::Create( "" ));

   // Get the associated response for the above request.
   HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)(myHttpWebRequest->GetResponse());
catch ( WebException^ e ) 
   Console::WriteLine( "This program is expected to throw WebException on successful run." +
      "\n\nException Message : " + e->Message );
   if ( e->Status == WebExceptionStatus::ProtocolError )
      Console::WriteLine( "Status Code: {0}", ( (HttpWebResponse^)(e->Response) )->StatusCode );
      Console::WriteLine( "Status Description: {0}", ( (HttpWebResponse^)(e->Response) )->StatusDescription );
catch ( Exception^ e ) 
   Console::WriteLine( e->Message );

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Portable Class Library

Supported in: Portable Class Library

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.