June 2002
Intermediate to advanced
816 pages
28h 12m
English
GetHttpCode
integer = HttpException.GetHttpCode( )
Returns an integer containing the HTTP status code contained within the exception. For most exceptions thrown by the ASP.NET intrinsic objects, this integer will be 500, indicating an HTTP server error.
integer
An integer variable to receive the HTTP code from the method.
The code example causes an exception by calling Server.Execute on a page that does not exist. The exception is then caught and the HTTP status code is displayed by calling GetHttpCode:
Sub Page_Load( )
Try
Server.Execute("Foo.aspx")
Catch HttpEx As HttpException
Message.Text = "ERROR:<br/>"
Message.Text &= "Http Status Code: " & _
HttpEx.GetHttpCode( ) & "<br/>"
End Try
End SubThis method is most useful for custom exceptions raised in methods that make HTTP calls, since it allows you to pass back the HTTP result code (404 for not found, 403 for access denied, etc.) to the calling client.
Read now
Unlock full access