我正在以如下方式处理异常HttpModule
:
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 { }
}
}
对于HTTP 状态代码(例如:302、404、503 等),一切正常。但是,对于IIS 状态码(例如:401.5、403.4 等),是否可以将GetHttpCode
这些作为其返回值是整数来检索?