我想在我的asp.net应用程序中使用wcf服务,该应用程序使用集成的Windows身份验证,但对Model.svc的所有请求都是401 Unauthorized。 如果我将clientCredentialType =“Windows”更改为clientCredentialType =“Ntlm”,则每个请求都是未经授权的2次,第3个请求成功。
这是我的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>
答案 0 :(得分:1)
未经授权和第三次工作2次是协议的一部分。这就是NTLM身份验证的工作方式。这会造成问题吗? WCF用于处理此类场景,因此您的WCF身份验证调用将正常工作。