Application_Error未在生产服务器上触发。但它在我们的本地服务器和其他亚马逊服务器上工作。在我们的本地服务器上有windows7操作系统和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);
}
}
答案 0 :(得分:-2)
发布时,尝试启用“发布期间预编译”,这应在发布文件夹中包含PrecompiledApp.config