Dot-Net-4.0

IIS Express HTTP 錯誤 401.2 - 未經授權

  • April 19, 2011

我已經嘗試了這篇文章中的建議,但我無法在 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

確保您的 applicationhost.config 文件中有如下內容

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

這個文件可能在%HOMEPATH%\Documents\IISExpress\config\

引用自:https://stackoverflow.com/questions/5720471