我为我的应用程序设置了自定义错误页面:
<customErrors mode="On" defaultRedirect="~/errors/GeneralError.aspx"
/>
Run Code Online (Sandbox Code Playgroud)
在Global.asax,Application_Error()中,以下代码用于获取异常详细信息:
Exception ex = Server.GetLastError();
if (ex != null)
{
if (ex.GetBaseException() != null)
ex = ex.GetBaseException();
}
Run Code Online (Sandbox Code Playgroud)
当我到达我的错误页面(〜/ errors/GeneralError.aspx.cs)时,Server.GetLastError()为null
有没有什么办法可以在错误页面上获取异常详细信息,而不是在Global.asax.cs中?
Vista/IIS7上的ASP.NET 3.5