global中Application
protected void Application_Start(object sender, EventArgs e)
{
HttpContext.Current.Application["webName"] = "哇哈哈哈~~~~~~~~~~" + DateTime.Now;
}
/// <summary>
/// 当整个网站 的任意页面 出现异常时 会执行
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Application_Error(object sender, EventArgs e)
{
//记录错误日志
HttpApplication app = sender as HttpApplication;
string errPath = app.Context.Request.MapPath("/err.txt");
System.IO.File.AppendAllText(errPath, HttpContext.Current.Server.GetLastError().Message);
}

浙公网安备 33010602011771号