2011-03-01 163 views
0

我想在IIS中託管我的WCF服務,它支持Windows身份驗證。我能夠使用Framework 3.5來完成它,但是當我將Framework更改爲4.0時,它會給出下面的錯誤。.net 4.0 + WCF + WIndows身份驗證+ IIS

此服務的安全設置需要「匿名」身份驗證,但它沒有爲承載此服務的IIS應用程序啓用。

我能夠在開發服務器上託管服務。但是我們必須使用IIS來完成它。

<?xml version="1.0"?> 
<configuration> 
    <system.web> 
     <compilation debug="true" targetFramework="4.0"> 
     </compilation> 
     </system.web> 
    <system.serviceModel> 
     <bindings> 
      <basicHttpBinding> 
       <binding name="BasicHttpEndpointBinding"> 
        <security mode="TransportCredentialOnly"> 
         <transport clientCredentialType="Windows"/> 
        </security> 
       </binding> 
      </basicHttpBinding> 
     </bindings> 
     <services> 
      <service name="Service1"> 
       <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpointBinding" name="BasicHttpEndpoint" contract="IService1"> 
        <identity> 
         <dns value="localhost"/> 
        </identity> 
       </endpoint>   
      </service> 
     </services> 
     <behaviors> 
      <serviceBehaviors> 
       <behavior> 
        <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment --> 
        <serviceMetadata httpGetEnabled="true"/> 
        <!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information --> 
        <serviceDebug includeExceptionDetailInFaults="false"/> 
       </behavior> 
      </serviceBehaviors> 
     </behaviors> 
     <serviceHostingEnvironment multipleSiteBindingsEnabled="true"/> 
    </system.serviceModel> 
    <system.webServer> 
     <modules runAllManagedModulesForAllRequests="true"> 
     </modules> 
    </system.webServer> 
</configuration> 

回答

0

This article有關於如何爲IIS7啓用匿名訪問的信息。

從UI,你需要做到以下幾點:

  • 打開IIS管理器,然後左鍵點擊你的網站/應用
  • 在功能窗格中,雙擊驗證
  • 在身份驗證頁面,右鍵單擊匿名身份驗證項目並選擇啓用。
+0

我不想做匿名訪問。它應該僅基於Windows身份驗證。 Anonymouss身份驗證取消了Windows身份驗證的所有優點。 – 2011-03-01 06:10:46

+0

由於您的服務需要匿名身份驗證。將httpGetEnabled設置爲false應該刪除該要求。 – 2011-03-01 06:30:51

+0

即使我將它保留爲假,我也會得到同樣的錯誤。相同的配置適用於3.5。 – 2011-03-01 06:37:36