选项 1:
编辑\My Documents\IISExpress\config\applicationhost.config
文件并启用 windowsAuthentication,即:
<system.webServer>
...
<security>
...
<authentication>
<windowsAuthentication enabled="true" />
</authentication>
...
</security>
...
</system.webServer>
选项 2:
解锁 \My Documents\IISExpress\config\applicationhost.config 中的 windowsAuthentication 部分,如下所示
<add name="WindowsAuthenticationModule" lockItem="false" />
将所需身份验证类型的覆盖设置更改为“允许”
<sectionGroup name="security">
...
<sectionGroup name="system.webServer">
...
<sectionGroup name="authentication">
<section name="anonymousAuthentication" overrideModeDefault="Allow" />
...
<section name="windowsAuthentication" overrideModeDefault="Allow" />
</sectionGroup>
</sectionGroup>
在应用程序的 web.config 中添加以下内容
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<system.webServer>
<security>
<authentication>
<windowsAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</configuration>
下面的链接可能会有所帮助:
http ://learn.iis.net/page.aspx/376/delegating-configuration-to-webconfig-files/
安装 VS 2010 SP1 后,可能需要应用选项 1 + 2 才能使 Windows 身份验证正常工作。此外,您可能需要在 IIS Express applicationhost.config 中将匿名身份验证设置为 false:
<authentication>
<anonymousAuthentication enabled="false" userName="" />
对于 VS2015,IIS Express 应用程序主机配置文件可能位于此处:
$(solutionDir)\.vs\config\applicationhost.config
并且<UseGlobalApplicationHostFile>
项目文件中的选项选择默认或特定于解决方案的配置文件。