全局文件(Global.asax)通常用于跟踪应用程序级别事件,这些事件可在不同的登录用户之间共享,因此可能无法在Global.asax事件中获取会话(session)值。
对于错误日志记录,您可以使用httpModule。
以下链接介绍了如何使用httpModule进行错误日志记录:
http://www.codeproject.com/Articles/16171/An-HTTP-Module-for-ASP-NET-Error-Handling
以下链接介绍了如何在httpModule中获取会话(session)值:
string value = HttpContext.Current.Session["user"] as string;
if (String.IsNullOrEmpty(value))
{
//your Code here
}