2011-08-23 109 views
1

我想在使用集成Windows身份驗證但是所有的請求到我的Model.svc我的asp.net應用程序使用WCF服務是401未授權。 如果我將clientCredentialType =「Windows」更改爲clientCredentialType =「Ntlm」,那麼每個請求都會被未經授權2次,第三次請求會成功。請求WCF服務是未經授權的

這裏是我的web.config:

<configuration> 
    <appSettings> 
    </appSettings> 
    <connectionStrings/> 
    <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    <authentication mode="Windows" /> 
    </system.web> 
    <!--WCF Configuration--> 
    <system.serviceModel> 
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" aspNetCompatibilityEnabled="true"/> 
    <bindings> 
     <webHttpBinding> 
     <binding name="WebHttpBinding_IModel"> 
      <security mode="TransportCredentialOnly"> 
      <transport clientCredentialType="Windows" /> 
      </security> 
     </binding> 
     </webHttpBinding> 
    </bindings> 
    <client /> 
    <services> 
     <service behaviorConfiguration="ServiceBehavior" name="Model"> 
     <endpoint address="" behaviorConfiguration="JsonBehavior" binding="webHttpBinding" bindingConfiguration="WebHttpBinding_IModel" contract="IModel"> 
      <identity> 
      <dns value="localhost" /> 
      </identity> 
     </endpoint> 
     </service> 
    </services> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="JsonBehavior"> 
      <webHttp /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true"/> 
      <serviceDebug includeExceptionDetailInFaults="true"/> 
     </behavior> 
    </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 

回答

1

2次未經授權的和第三工作是協議的一部分。這是NTLM身份驗證的工作方式。這是否構成問題? WCF是用來處理這種情況的,所以你的WCF驗證呼叫會正常工作。

+0

我想使用Windows身份驗證。反正......我只是在真正的IIS上測試過它,它只是起作用。所以這只是asp.net開發服務器和windows-auth的問題 – wuhi