/*****************global.asax************************/
void Application_Error(object sender, EventArgs e)
{
// 在出现未处理的错误时运行的代码
Exception error = GetExp(Server.GetLastError());
HttpContext context = HttpContext.Current;
System.Text.StringBuilder sb = new StringBuilder();
sb.Append(error.Message);
sb.Append(error.Source);
sb.Append(error.StackTrace);
SiteLog.Add(sb.ToString());//自己定义的日志记录方法
}
Exception GetExp(Exception ex)
{
return ex.InnerException == null ? ex : ex.InnerException;
}
/*****************************************/