I'm handling exceptions with an HttpModule
in a manner such as this:
int errorCode = 500;
HttpApplication httpApp = (HttpApplication)sender;
try
{
if (httpApp.Server != null)
{
Exception ex;
for (ex = httpApp.Server.GetLastError(); ex != null; ex = ex.InnerException)
{
try
{
HttpException httpEx = ex as HttpException;
if (httpEx != null)
errorCode = httpEx.GetHttpCode();
// ... retrieve appropriate content based on errorCode
}
catch { }
}
}
For HTTP status codes (ex: 302, 404, 503, etc) everything works great. However, for IIS status codes (ex: 401.5, 403.4, etc), can GetHttpCode
retrieve these as its return value is an integer?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…