开发者

NullReferenceException in Global.asax when referencing Context.User.Identity in Session_Start

When I am debugging an application in ASP.NET, after about ~5 minutes I get a NullR开发者_如何学运维efEx coming from global.asax.cs regarding:

protected void Session_Start(Object sender, EventArgs e)
        {
            WindowsIdentity identity = null;
            identity = (WindowsIdentity)(Context.User.Identity);
...

Context is Null at this point. I am a noob in ASP.NET with regards to Global.asax.cs. This code was written by another developer.

EDIT: This is the code with HttpContext...

    protected void Session_Start(Object sender, EventArgs e)
    {
    WindowsIdentity identity = null;
    identity = (WindowsIdentity)(HttpContext.Current.User.Identity);


Try:

identity = (WindowsIdentity)(HttpContext.Current.User.Identity); 

edited to be more clear (I hope...)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜