Context.User is Nothing ONLY when trying to debug
I have a project that I have upgraded from .NET 1.1 to .NET 4.0. The project uses Windows Authentication (internal Intranet webpage). I setup Windows Authentication in IIS 7.5 (running Windows 7) following the steps laid out in this article.
http://www.iis.net/ConfigReference/system.webServer/security/authentication/windowsAuthentication
I can now build the project. I can open the project by opening IE and typing in the URL on localhost. However, if I try to debug the project it throws an NullReferenceException on this line in the Application_AuthenticateRequest in Global.asax.
dt = oDBLookup.GetPIMSUserRoles(Context.User.Identity.Name)
If I set a breakpoint there I see that Context.User is Nothing. If I set a breakpoint in the same place on the 1.1 project (different box, running IIS 6) it has my Windows Credentials.
Why wo开发者_如何转开发uld Context.User be Nothing ONLY when I am trying to run from the debugger in Visual Studio 2010 Professional, and not when I open the web project directly in IE?
Thanks in advance.
I deleted the solution file (which had been upgraded), created a new one in VS 2010 and the problem disappeared. I would put this as an answer but my reputation is below 100 so I can't answer my own question.
精彩评论