我已经编写了我的第一个WCF Web服务,它在我自己的本地测试Web服务器上运行良好,但是当我将它部署到IIS时出现错误。
我们的IIS服务器使用集成的身份验证,并且不允许匿名访问。从what I've read开始,我需要将绑定的安全模式设置为TransportCredentialOnly
。 web.config
中的整个部分是:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="VZW.TrainingPortfolioManager.Website.TPMAspNetAjaxBehavior">
<enableWebScript />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
<services>
<service name="VZW.TrainingPortfolioManager.Website.TPM">
<endpoint address="" behaviorConfiguration="VZW.TrainingPortfolioManager.Website.TPMAspNetAjaxBehavior"
binding="webHttpBinding" contract="VZW.TrainingPortfolioManager.Website.TPM" />
</service>
</services>
<bindings>
<basicHttpBinding>
<binding>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
</system.serviceModel>
但是,当我在浏览器中加载Web服务时,收到错误消息:
Security settings for this service require 'Anonymous' Authentication but it is not enabled for the IIS application that hosts this service.
还有什么我需要更改或配置才能使其正常工作吗?
答案 0 :(得分:0)
想出来。 binding
上的endpoint
属性必须与<bindings>
集合中的节点匹配。以下内容适用:
<bindings>
<webHttpBinding>
<binding>
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</webHttpBinding>
</bindings>