【发布时间】:2015-04-27 06:15:07
【问题描述】:
Application_Error 未在生产服务器上触发。但它在我们的本地服务器和其他亚马逊服务器上工作。在我们的本地服务器有 windows7 OS 和 IIS (7.5) 版本,但生产服务器有 Windows8 和 IIS (8+) 版本。任何人都有任何想法。
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
Exception ex = Server.GetLastError().GetBaseException();
string cls = ex.TargetSite.DeclaringType.Name;
string mtd = ex.TargetSite.Name;
string ErrorMessage = ex.Message;
string page = Request.Path;
string url = Request.PhysicalPath;
string StackTrace = "";
string inputdata = "";
if (ErrorMessage != "File does not exist.")
{
StackTrace = ex.StackTrace;
foreach (string i in Session.Contents)
{
if (Session[i] != null)
{
if (inputdata != "")
{
inputdata = inputdata + " , [" + i + "] = " + Session[i].ToString();
}
else
{
inputdata = "[" + i + "] = " + Session[i].ToString();
}
}
}
string flg = objBus.insertException(page, "", ErrorMessage, StackTrace, "", url, Session["UserID"].ToString(), inputdata,"");
//string flg = "0";
//Response.Redirect("~/ErrorPage.aspx?errorId=" + flg, false);
Server.Transfer("~/ErrorPage.aspx?errorId=" + flg, false);
}
}
【问题讨论】: