IIS 7.5 中的 Windows 身份验证问题
我是 IIS 7.5 的新手,我正在尝试让网站使用 Windows 身份验证。它是一个 ASP.NET 4.0 应用程序,设置为默认网站下的应用程序,并且运行 ASP.NET 4 应用程序池。该应用程序设置为禁用匿名身份验证并启用 Windows 身份验证。
该网站未正确进行身份验证 - 我可以在事件日志中看到错误(这是一个 Null Reference
错误,与某些使用 Context.User
的代码有关)并且详细信息显示 IsAuthenticated=False
且 User
为空。
我已在 Web.config 中的
下设置了 Authentication Mode = Windows
,并尝试了各种其他配置设置,但没有成功。
我尝试过使用 ASP.NET 经典应用程序池,但出现错误
处理程序“ExtensionlessUrl-ISAPI-4.0_64bit”有一个错误的模块 模块列表中的“IsapiModule”
我更愿意使用 ASP.NET 4 应用程序池使其工作。谁能建议我需要做什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
抱歉,我找到答案后忘记发布答案了。事实上,身份验证配置没有任何问题,这与我在 Global.asax 中过早引用 Context.User 有关。
在新的集成模式中,身份验证的工作方式与经典模式不同,并且在 Global.asax 中的 Application_AuthenticateRequest 事件中,身份验证尚未发生,因此 Context.User 为 null,因此我得到了异常,并且日志显示 IsAuthenticated 为 false。我将调用 Context.User 的代码行移至 Application_PostAuthenticateRequest 中,现在它正在工作。
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.
看一下 IIS Express Windows 身份验证
唯一的区别是,IIS 7.5
applicationhost.config
文件位于%systemroot%\System32\inetsrv\config\applicationHost.config
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