简体   繁体   中英

Windows Authentication issue in IIS 7.5

I'm new to IIS 7.5 and I am trying to get a site working with Windows Authentication. It's an ASP.NET 4.0 application which is set up as an application under the default website and it is running the ASP.NET 4 app pool. The application is set up with Anonymous Authentication disabled and Windows Authentication enabled.

The site is not authenticating properly - I can see an error in the event log (this is a Null Reference error to do with some code that uses Context.User ) and the detail says IsAuthenticated=False and the User is blank.

I have set Authentication Mode = Windows under <system.web> in my Web.config and have tried various other config settings without success.

I've tried using the ASP.NET classic app pool but get an error

Handler "ExtensionlessUrl-ISAPI-4.0_64bit" has a bad module "IsapiModule" in its module list

I'd prefer to get it working using the ASP.NET 4 app pool if possible. Can anyone advise what I need to do?

Sorry, I forgot to post the answer when I found it. In actual fact there was nothing wrong with the authentication configuration, it was to do with my referencing Context.User too early in Global.asax.

In the new integrated mode the authentication works differently to classic mode and in the Application_AuthenticateRequest event in Global.asax the authentication hasn't happened yet so Context.User is null hence the exception I got and the fact that the log shows IsAuthenticated as false. I moved the line of code that calls Context.User into Application_PostAuthenticateRequest and it's working now.

Take a look at IIS Express Windows Authentication

Only difference is, IIS 7.5 applicationhost.config file is located at %systemroot%\System32\inetsrv\config\applicationHost.config

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM