Get long descriptions of http status codes in asp.net (IIS7)
I've set up a custom error page to handle errors thrown through my site.
I'm running asp.net 3.5 with IIS 7.0 on Godaddy shared hosting ("deluxe" account).
No开发者_开发问答rmally, if I set Response.StatusCode = 412 the server outputs:
Server Error
412 - Precondition set by the client failed when evaluated on the Web server.
The request was not completed due to preconditions that are set in the request header.
Preconditions prevent the requested method from being applied to a resource other than the one intended. An example of a precondition is testing for expired content in the page cache of the client.
I already figured out how to prevent the server from automatically outputting the above message and instead execute my custom error page. What I'm stuck on now is figuring out how to access the long description of the error message.
Response.StatusDescription is "Precondition Failed" - which is expected...but is not really what I want.
Is there anyway to get the long description the server normally sends?
*Note that in order to prevent the default error message I had to set Response.TrySkipIisCustomErrors = true
immediately after setting the Response.StatusCode to 412.
The long description is hard coded into 412.htm in this case. Since you have set up your own custom error page, this default supplied page is no longer used. This verbose message is not a part of the ASP.NET Response object.
精彩评论