当我在ASP.NET中调试应用程序时,大约5分钟后,我得到一个来自global.asax.cs的NullRefEx:
protected void Session_Start(Object sender, EventArgs e)
{
WindowsIdentity identity = null;
identity = (WindowsIdentity)(Context.User.Identity);
...
此时上下文为空。关于Global.asax.cs,我是ASP.NET中的菜鸟。此代码由另一位开发人员编写。
编辑: 这是HttpContext的代码......
protected void Session_Start(Object sender, EventArgs e)
{
WindowsIdentity identity = null;
identity = (WindowsIdentity)(HttpContext.Current.User.Identity);
答案 0 :(得分:0)
尝试:
identity = (WindowsIdentity)(HttpContext.Current.User.Identity);
编辑得更清楚(我希望......)