【发布时间】:2010-11-29 22:28:02
【问题描述】:
我想在 Azure ASP.NET Web 应用程序中显示一个自定义错误页面
<p>Oops - something went wrong.</p>
<p>The most common problem is that you tried to do something that the database enforces shouldn't happen.</p>
<p>The error is:</p>
在 web.config 我有:
<customErrors mode="On" defaultRedirect="Error.aspx" />
和 global.asax:
protected void Application_Error(object sender, EventArgs e)
{
Exception objErr = Server.GetLastError().GetBaseException();
string err = "Error Caught in Application_Error event\n" +
"Error in: " + Request.Url.ToString() +
"\nError Message:" + objErr.Message.ToString() +
"\nStack Trace:" + objErr.StackTrace.ToString();
EventLog.WriteEntry("Sample_WebApp", err, EventLogEntryType.Error);
}
问题:如何在 Error.aspx 页面上显示完整的异常?
【问题讨论】: