IIS Express HTTP错误401.2 - 未经授权

时间:2011-04-19 17:48:08

标签: .net-4.0 windows-authentication iis-express

我已尝试this post中的建议,但我无法在Vision Studio 2010中使用IIS身份验证进行Windows身份验证。现在我收到以下错误: 401.2 Error

以下是我的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

3 个答案:

答案 0 :(得分:33)

确保applicationHA.config文件中包含以下内容

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

此文件可能位于%HOMEPATH%\Documents\IISExpress\config\

答案 1 :(得分:4)

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

_vti_bin/ListData.svc

我开始配置windows身份验证,如apphost.config中此页面的一些帖子所述。最后,工作配置不能有Negotiate provider:

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

必须禁用匿名身份验证:

<anonymousAuthentication enabled="false" />
<windowsAuthentication enabled="true" />

答案 2 :(得分:0)

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

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules runAllManagedModulesForAllRequests="true" />
        <security>
            <authentication>
                <windowsAuthentication enabled="true" />
            </authentication>
        </security>
</system.webServer>
相关问题