This documentation is archived and is not being maintained.
WebException::Status Property
Visual Studio 2010
Gets the status of the response.
Assembly: System (in System.dll)
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.
try { // Create a web request for an unknown server (this raises the WebException). HttpWebRequest^ myHttpWebRequest = (HttpWebRequest^)(WebRequest::Create( "http://unknown.unknown.com" )); // Get the associated response for the above request. HttpWebResponse^ myHttpWebResponse = (HttpWebResponse^)(myHttpWebRequest->GetResponse()); myHttpWebResponse->Close(); } 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 ); }
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.
Show: