我有一个ASP.NET MVC 2页面。在错误或异常期间,Global.asax中的Application_Error方法不会在IIS7上触发。Global.asax Application_Error未在IIS上触发
**但它确实火,如果我跑从VS2010的Web应用程序(本地主机:someport)
我的代码(C#):
protected void Application_Error(object sender, EventArgs e)
{
Exception exception = Server.GetLastError();
string requestedUrl = HttpContext.Current.Request.Url.ToString();
Response.Clear();
// do something
Server.ClearError();
Server.Redirect("Error");
}
我的配置:
<customErrors mode="On" defaultRedirect="~/Error">
</customErrors>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules runAllManagedModulesForAllRequests="true" />
</system.webServer>
请帮忙。