27

我已经尝试了这篇文章中的建议,但我无法在 Vision Studio 2010 中使用 IIS Express 进行 Windows 身份验证。现在我收到以下错误: 401.2 错误

这是我的 applicationhost.config 文件条目:

...
<add name="WindowsAuthenticationModule" lockItem="false" />
...
<authentication>

    <anonymousAuthentication enabled="true" userName="" />

    <basicAuthentication enabled="false" />

    <clientCertificateMappingAuthentication enabled="false" />

    <digestAuthentication enabled="false" />

    <iisClientCertificateMappingAuthentication enabled="false">
    </iisClientCertificateMappingAuthentication>

    <windowsAuthentication enabled="true" />
</authentication>
...
<sectionGroup name="authentication">
    <section name="anonymousAuthentication" overrideModeDefault="Allow" />
    <section name="basicAuthentication" overrideModeDefault="Allow" />
    <section name="clientCertificateMappingAuthentication" overrideModeDefault="Allow" />
    <section name="digestAuthentication" overrideModeDefault="Allow" />
    <section name="iisClientCertificateMappingAuthentication" overrideModeDefault="Allow" />
    <section name="windowsAuthentication" overrideModeDefault="Allow" />
</sectionGroup>

我的 web.config:

<system.web>
    <authentication mode="Windows" /> 
</system.web>
<system.webServer>
    <security>
        <authentication>
            <anonymousAuthentication enabled="false" />
            <windowsAuthentication enabled="true" />        
        </authentication>
    </security>
</system.webServer>

这是.NET 4

4

3 回答 3

38

确保您的 applicationhost.config 文件中有如下内容

<windowsAuthentication enabled="true">
  <providers>
    <add value="Negotiate" />
    <add value="NTLM" />
   </providers>
</windowsAuthentication>

这个文件可能在%HOMEPATH%\Documents\IISExpress\config\

于 2011-04-27T15:43:23.687 回答
5

当我想更新服务参考时,我在带有 IIS 8.0 Express 的 VS 2013 中遇到了这样的问题。弹出一个对话框,询问用户名/密码。服务 url 中添加了一个奇怪的子字符串:

_vti_bin/ListData.svc

我开始配置 Windows 身份验证,如本页中 applicationhost.config 中的一些帖子中所述。最后,工作配置不能有协商提供者:

<windowsAuthentication enabled="true">
  <providers>
    <!--<add value="Negotiate" />-->
    <add value="NTLM" />
   </providers>
</windowsAuthentication>

并且必须禁用匿名身份验证:

<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />
于 2014-06-03T12:41:00.527 回答
0

尝试将以下内容添加到您的 web.config。

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
    <security>
        <authentication>
            <windowsAuthentication enabled="true" />
        </authentication>
    </security>
</system.webServer>
于 2011-04-21T14:49:05.227 回答