相关疑难解决方法(0)

ASP.NET自定义错误页面 - Server.GetLastError()为null

我为我的应用程序设置了自定义错误页面:

<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

asp.net web-applications exception custom-error-pages

111
推荐指数
6
解决办法
11万
查看次数