I handle exceptions with an HttpModule in a way like 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 fine. However, for IIS status codes (for example: 401.5, 403.4, etc.), can GetHttpCode extract them since its return value is an integer?
Bullines
source share