【发布时间】:2010-09-25 11:22:59
【问题描述】:
我为我的应用程序设置了一个自定义错误页面:
<customErrors mode="On" defaultRedirect="~/errors/GeneralError.aspx"
/>
在 Global.asax 的 Application_Error() 中,以下代码用于获取异常详细信息:
Exception ex = Server.GetLastError();
if (ex != null)
{
if (ex.GetBaseException() != null)
ex = ex.GetBaseException();
}
当我到达我的错误页面 (~/errors/GeneralError.aspx.cs) 时,Server.GetLastError() 为空
有什么方法可以在错误页面而不是 Global.asax.cs 中获取异常详细信息?
Vista/IIS7 上的 ASP.NET 3.5
【问题讨论】:
-
也适用于带有 Cassini 的 Win7 上的 ASP.NET 4.0
-
添加“
" 作为确认答案
标签: asp.net exception web-applications custom-error-pages