Does anyone know if there is a good programatic way (not using the CustomError settings) to catch / handle an 404 error coming from the StaticFileModule in integrated pipeline mode on a IIS7?
有没有人知道是否有一个好的编程方式(不使用CustomError设置)来捕获/处理来自IIS7上集成管道模式的StaticFileModule的404错误?
1 个解决方案
#1
have you tried overriding the HttpApplication.Error event in your Global.asax.cs:
你有没有试过覆盖Global.asax.cs中的HttpApplication.Error事件:
protected void Application_Error (object sender, EventArgs e)
{
HttpException httpException = Context.Error as HttpException;
if (httpException != null)
{
switch (httpException.GetHttpCode ())
{
case 404:
// do stuff here
//Server.ClearError ();
break;
}
}
}
#1
have you tried overriding the HttpApplication.Error event in your Global.asax.cs:
你有没有试过覆盖Global.asax.cs中的HttpApplication.Error事件:
protected void Application_Error (object sender, EventArgs e)
{
HttpException httpException = Context.Error as HttpException;
if (httpException != null)
{
switch (httpException.GetHttpCode ())
{
case 404:
// do stuff here
//Server.ClearError ();
break;
}
}
}