//添加 Global.asax 文件,在下面的方法加入自己的错误日志记录类,
//此处自定义的类名为: WriteLog.cs 里面有个方法 ToTxt(Exception e,string file);
//记录日志
void Application_Error
(object sender,
EventArgs e)
{
// 在出现未处理的错误时运行的代码
Exception x = Server.GetLastError().GetBaseException();
WriteLog.ToTxt(x, Server.MapPath("~/Log/" +
DateTime.Now.ToString("yyyy-MM-dd") + ".log"));
Server.ClearError();
//转到友好页面
Response.Redirect("~/Help/ErrorPage.html");
}