//出现未捕捉的异常时,系统调用本方法,一般用于记录日志。错误页的重定向一般在web.config中设置。
protected void Application_Error(object sender, EventArgs e)
{
//GetLastError() 返回Exception实例,任何Exception实例都包含如下属性,可将如下属性写入日志。
Exception exp = HttpContext.Current.Server.GetLastError();
string err = HttpContext.Current.Server.GetLastError().Message;
string cls = HttpContext.Current.Server.GetLastError().Source;
string func = HttpContext.Current.Server.GetLastError().TargetSite.Name;
}