我一直在試圖創建一個使用基本身份驗證,到目前爲止,我一直在打,指出服務想即使我想我匿名身份驗證錯誤消息WCF服務'd配置web.config以使用基本身份驗證。WCF +基本驗證 - 不會停止使用匿名身份驗證
我花了幾個小時嘗試和失敗找到一個解決我的問題,所以我想在這裏試一試。我懷疑這是我忽略的東西。
這是我正在做的。我創建了一個Web項目,增加了一個WCF服務,創建另一個Web項目,並增加了一個單獨的.aspx頁面中來測試服務。我沒有改變任何東西在默認的WCF服務的配置。我可以部署到IIS,如果我打開一個瀏覽器窗口並導航到該頁面,該服務一旦啓用匿名身份驗證工作正常。我也可以使用測試頁面訪問該服務,而不會出現任何問題。
然後,我更改爲使用基本身份驗證(見下面的服務的web.config),並重新部署服務。我沒有將IIS的身份驗證更改爲使用基本身份驗證,因此它仍設置爲使用匿名身份驗證。我刷新了瀏覽器並顯示了服務。測試網頁仍然能夠訪問該服務。
然後,我將IIS中的身份驗證方案更改爲使用「基本」,並確保所有其他類型的身份驗證都被禁用。當我嘗試訪問該服務時,收到錯誤消息「此服務的安全設置需要'匿名'身份驗證,但未啓用託管此服務的IIS應用程序」。
這裏是我的服務的web.config :
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
<bindings>
<wsHttpBinding>
<binding name="basicAuthBinding">
<security mode="Transport">
<transport clientCredentialType="Basic" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="TestService">
<endpoint address="http://localhost:7000/BA.svc" binding="wsHttpBinding" bindingConfiguration="basicAuthBinding" name="BasicEndpoint" />
</service>
</services>
</system.serviceModel>
</configuration>
任何想法爲什麼這不起作用?