一段时间以来,我一直在研究启用 Ajax 的 WCF 服务,但从未使用 Windows 身份验证。直接从 VS 2010 运行时它工作正常,但当部署到 Web 服务器时,它会引发错误。
这是我的 web.config:
<configuration>
<system.web>
<compilation debug="false" targetFramework="4.0"/>
<pages controlRenderingCompatibilityVersion="3.5" clientIDMode="AutoID"/>
<authentication mode="Windows" />
</system.web>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="BasicHttpEndpointBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="GISAlloc.Services.GISServiceBehavior">
<serviceMetadata httpGetEnabled="false"/>
<serviceDebug includeExceptionDetailInFaults="true"/>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="GISAlloc.Services.GISServiceAspNetAjaxBehavior">
<enableWebScript/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true"/>
<services>
<service name="GISAlloc.Services.GISService" behaviorConfiguration="GISAlloc.Services.GISServiceBehavior">
<endpoint address="" bindingConfiguration="BasicHttpEndpointBinding" binding="basicHttpBinding" contract="GISAlloc.Services.GISService"/>
</service>
</services>
</system.serviceModel>
</configuration>
但是当我尝试从 asp.net 获取数据时,我收到错误 500,这是来自我的 Windows 日志:
WebHost 未能处理请求。发件人信息:System.ServiceModel.Activation.HostedHttpRequestAsyncResult/51925686 异常:System.ServiceModel.ServiceActivationException:服务“/Services/GISService.svc”由于编译过程中的异常而无法激活。异常消息是:在 IIS 上配置的扩展保护设置与在传输上配置的设置不匹配。ExtendedProtectionPolicy.PolicyEnforcement 值不匹配。IIS 的值为 WhenSupported,而 WCF 传输的值为 Never.. ---> System.NotSupportedException:在 IIS 上配置的扩展保护设置与在传输上配置的设置不匹配。ExtendedProtectionPolicy.PolicyEnforcement 值不匹配。
这是我脚本中的代码:
var navService = new GISAlloc.GISService();
navService.GetGISList(shownav, null, null);
我究竟做错了什么?