Asp.net-Mvc

IIS Express 自動為我的項目禁用匿名身份驗證,為什麼?

  • March 16, 2012

當我將 ASP.NET MVC 項目從 Cassini Web 伺服器切換到 IIS Express 時,這將添加到我的applicationhost.config文件中:

<location path="MyProject">
   <system.webServer>
       <security>
           <authentication>
               <anonymousAuthentication enabled="false" />
               <windowsAuthentication enabled="false" />
           </authentication>
       </security>
   </system.webServer>
</location>

它導致網站無法載入 401.2 - 未經授權,我無法在 Web.config 級別修復它 - 然後它會抱怨該部分被鎖定在父級別(HTTP 500.19)。

我可以通過修改applicationhost.config文件來修復它,但我不明白為什麼在沒有為 vanilla ASP.NET MVC 項目添加這樣的部分時我需要這樣做。有什麼問題?

我正在使用 VS 11 beta,但也在 2010 SP1 中確認了這種奇怪的行為。IIS Express 說它是 7.5 版。

這是因為出於某種原因,這是在我的 csproj 文件中:

<IISExpressAnonymousAuthentication>disabled</IISExpressAnonymousAuthentication>

將其設置為enabled修復問題(也可以從 Visual Studio 中完成,選擇項目,F4,將屬性網格中的匿名身份驗證設置為**Enabled)。

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