简体   繁体   English

Windows IIS 7.5 中的身份验证问题

[英]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.我是 IIS 7.5 的新手,我正在尝试获取一个使用 Windows 身份验证的站点。 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.这是一个 ASP.NET 4.0 应用程序,它被设置为默认网站下的应用程序,它正在运行 ASP.NET 4 应用程序池。 The application is set up with Anonymous Authentication disabled and Windows Authentication enabled.该应用程序设置为禁用匿名身份验证并启用 Windows 身份验证。

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.该站点未正确进行身份验证 - 我可以在事件日志中看到一个错误(这是一个Null Reference错误,与使用Context.User的某些代码有关)并且详细信息IsAuthenticated=False并且User为空白。

I have set Authentication Mode = Windows under <system.web> in my Web.config and have tried various other config settings without success.我在 Web.config 中的<system.web>下设置了Authentication Mode = Windows并尝试了各种其他配置设置但均未成功。

I've tried using the ASP.NET classic app pool but get an error我尝试使用 ASP.NET 经典应用程序池,但出现错误

Handler "ExtensionlessUrl-ISAPI-4.0_64bit" has a bad module "IsapiModule" in its module list处理程序“ExtensionlessUrl-ISAPI-4.0_64bit”的模块列表中有一个错误模块“IsapiModule”

I'd prefer to get it working using the ASP.NET 4 app pool if possible.如果可能的话,我宁愿使用 ASP.NET 4 应用程序池让它工作。 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.事实上,认证配置并没有什么问题,这与我在 Global.asax 中过早引用 Context.User 有关。

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.在新的集成模式中,身份验证的工作方式与经典模式不同,在 Global.asax 中的 Application_AuthenticateRequest 事件中,身份验证尚未发生,因此 Context.User 是 null 因此我得到了异常,并且日志显示 IsAuthenticated 为假。 I moved the line of code that calls Context.User into Application_PostAuthenticateRequest and it's working now.我将调用 Context.User 的代码行移到 Application_PostAuthenticateRequest 中,它现在可以工作了。

Take a look at IIS Express Windows Authentication看看IIS快递Windows认证

Only difference is, IIS 7.5 applicationhost.config file is located at %systemroot%\System32\inetsrv\config\applicationHost.config唯一不同的是,IIS 7.5 applicationhost.config文件位于%systemroot%\System32\inetsrv\config\applicationHost.config

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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