Windows身份验证在IIS Express中不起作用,使用Visual Studio 2013,Windows 8进行调试
我刚刚将我的应用程序从Visual Studio 2012升级到了Visual Studio2013.我的Windows身份验证不再起作用.它给了我下面的错误.
I just upgraded my application from Visual studio 2012 to Visual studio 2013. My windows authentication is not working any more. It is giving me below error.
HTTP Error 401.2 - Unauthorized
You are not authorized to view this page due to invalid authentication headers.
在Visual Studio中,可以从网站属性本身中选择身份验证.因此,我禁用了匿名访问并启用了Windows身份验证,但它要求我提供用户名和密码,如下所示.即使我在这里提供域凭据.它仍然一次又一次地给我这个弹出窗口.
In visual studio there is option to select authentication from website properties itself. So I disabled anonymous access and enable windows authentication but it is asking me for username and password as below popup. Even if I give domain credentials here. Its is still giving me this popup again and again.
Web配置:
<authentication mode="Windows" />
<authorization>
<deny users="?" />
</authorization>
<identity impersonate="false" />
<trace enabled="true" />
IIS Express aspnetConfig:
<authentication>
<anonymousAuthentication enabled="false" userName="" />
<basicAuthentication enabled="false" />
<clientCertificateMappingAuthentication enabled="false" />
<digestAuthentication enabled="false" />
<iisClientCertificateMappingAuthentication enabled="false">
</iisClientCertificateMappingAuthentication>
<windowsAuthentication enabled="true">
<providers>
<add value="Negotiate" />
<add value="NTLM" />
</providers>
</windowsAuthentication>
</authentication>
<authorization>
<add accessType="Allow" users="*" />
</authorization>
<location path="Path">
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="true" />
<anonymousAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
</location>
如果您需要更多详细信息,请告诉我.
Let me know if you want more details on this.
更新:
我发现,如果我从web.config中删除以下行,它将开始工作.
I found out that if I remove below line from web.config than it start working.
<remove users="*" roles="" verbs="" />
请注意applicationhost.config的修改-在Visual Studio 2015中,我发现有时驻留在本地项目目录中
Be careful with the applicationhost.config modifications - in Visual Studio 2015 I've found that it sometimes resides in the local project directory.
例如:
DRIVE:\MYPROJECT\.vs\config\applicationhost.config
如果您不确定正在使用哪个applicationhost配置文件,则可以使用ProcMon& Monitor监视文件访问.然后根据路径"缩小结果范围,以查看VS在调试时实际读取的内容.
If you're not sure which applicationhost config file is being used, you can monitor file access with ProcMon & then narrow down the results based on "Path" to see what VS is actually reading at Debug time.
更新:这似乎也是Visual Studio 2017中的行为.
Update: This appears to be the behavior in Visual Studio 2017 as well.