2012-01-03 39 views
0

我在VisualStudio 2010中創建了一個簡單的WCF服務。我正在使用basicHttpBinding方法。WCF例外:此服務的安全設置需要'匿名'身份驗證

時,我認爲在瀏覽器中的.svc,我收到以下錯誤:

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

我的web.config的樣子,

<system.serviceModel> 
<bindings> 
<basicHttpBinding> 
<binding name="BasicHttpEndpointBinding"> 
<security mode="TransportCredentialOnly"> 
<transport clientCredentialType="Windows" /> 
</security> 
</binding> 
</basicHttpBinding> 
</bindings> 



    <services> 
     <service behaviorConfiguration="IAManagement.Service1Behavior" 
     name="IAManagement.Service1"> 
     <endpoint address="" binding="wsHttpBinding" contract="IAManagement.IService1"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
     <service behaviorConfiguration="IAManagement.CreateIABehavior" 
     name="IAManagement.CreateIA"> 
     <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpEndpointBinding" 
      name="BasicHttpEndpoint" contract="IAManagement.ICreateIA"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior name="IAManagement.Service1Behavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     <behavior name="IAManagement.CreateIABehavior"> 
      <serviceMetadata httpGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="false" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 

誰能幫助我在得到這個問題解決了嗎?由於

回答

0

你以下配置:

<binding name="BasicHttpEndpointBinding"> <security mode="TransportCredentialOnly"> <transport clientCredentialType="Windows" /> </security> </binding> 

是驗證使用Windows身份驗證和相同的設置還沒有在IIS中配置的客戶端。

如果您希望客戶端身份驗證類型爲Windows,然後進入IIS並選擇虛擬目錄,您可以找到一個名爲「身份驗證」的部分。雙擊,你可以找到「Windows身份驗證」作爲一個元素的狀態應該是「啓用」爲您的Web服務工作。

如果您不想要任何類型的身份驗證,那麼您需要將安全模式設置爲無,並且會在瀏覽器中顯示您的服務。

相關問題