我有一个 asp.net 应用程序,它什么都没有,直到我将它发布到 IIS。它一直说我必须添加我所做的自定义错误标签。
<customErrors mode="On" defaultRedirect="~/Errorpage/Booboo.aspx"/>
但它继续在 url aspxpatherror 中返回运行时错误页面。我整天都在谷歌上搜索这个错误的原因,但我似乎找不到它。
void Page_Load(object sender, System.EventArgs e)
{
}
public void Page_Error(object sender, EventArgs e)
{
Exception objErr = Server.GetLastError().GetBaseException();
string err = "<b>Error Caught in Page_Error event</b><hr><br>" +
"<br><b>Error in: </b>" + Request.Url.ToString() +
"<br><b>Error Message: </b>" + objErr.Message.ToString() +
"<br><b>Stack Trace:</b><br>" +
objErr.StackTrace.ToString();
Response.Write(err.ToString());
Server.ClearError();
}
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);
Server.ClearError();
//additional actions...
}
这是我的错误页面