【发布时间】:2011-11-01 16:18:07
【问题描述】:
我有一个 ASP.NET MVC 2 页面。在错误或异常期间,Global.asax 中的 Application_Error 方法不会在 IIS7 上触发。
**但是如果我从 VS2010 (localhost:someport) 运行 Web 应用程序,它会触发
我的代码(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>
请帮忙。
【问题讨论】:
标签: c# asp.net-mvc iis-7 global-asax