在我的应用程序中,我Application_Error
用来记录应用程序用户。
但在我的错误代码中,我在错误日志系统中注册错误并在错误页面上重定向用户。
现在如果有多个用户,那么它会影响所有登录用户吗?
我也在保存价值 Application["ErrorDetails"]
这会对所有用户造成问题吗?下面是代码
protected void Application_Error(object sender, EventArgs e)
{
Exception objErr = Server.GetLastError().GetBaseException();
StringBuilder sb = new StringBuilder();
sb.Append("Error Caught in Application_Error event" + Environment.NewLine);
sb.Append("Error Message:" + objErr.Message.ToString() + Environment.NewLine);
sb.Append("Stack Trace:" + objErr.StackTrace.ToString() + Environment.NewLine);
sb.Append(Environment.NewLine);
log4net.ILog logger = log4net.LogManager.GetLogger(typeof(Global));
logger.Error(sb.ToString());
Exception ex = Server.GetLastError();
if (ex is ThreadAbortException)
{
Server.ClearError();
return;
}
Server.ClearError();
Application["ErrorDetails"] = sb.ToString();
// redirect to the error page
HttpCookie SMTPCookies = new HttpCookie("ErrorDetails");
Response.Cookies["ErrorDetails"]["ErrorUrl"] = Request.Url.ToString();
Response.Cookies["ErrorDetails"]["Message"] = objErr.Message.ToString();
Response.Cookies["ErrorDetails"]["StackTrace"] = objErr.StackTrace.ToString();
Response.Cookies["ErrorDetails"].Expires = DateTime.Now.AddSeconds(60);
Response.Redirect("~/pages/ErrorPage.aspx");
}