/*****************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;
}
/*****************************************/