我一直在使用支持Ajax的WCF服务,但从未使用Windows身份验证。从VS 2010直接运行时它工作正常,但是当部署到Web服务器时,它会引发错误。启用了Ajax的WCF服务不起作用
这是我的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 failed to process a request. Sender Information: System.ServiceModel.Activation.HostedHttpRequestAsyncResult/51925686 Exception: System.ServiceModel.ServiceActivationException: The service '/Services/GISService.svc' cannot be activated due to an exception during compilation. The exception message is: The extended protection settings configured on IIS do not match the settings configured on the transport. The ExtendedProtectionPolicy.PolicyEnforcement values do not match. IIS has a value of WhenSupported while the WCF Transport has a value of Never.. ---> System.NotSupportedException: The extended protection settings configured on IIS do not match the settings configured on the transport. The ExtendedProtectionPolicy.PolicyEnforcement values do not match. IIS has a value of WhenSupported while the WCF Transport has a value of Never.
这是我的脚本代码:
var navService = new GISAlloc.GISService();
navService.GetGISList(shownav, null, null);
我在做什么错了?
我已在IIS一些更新,现在我可以查看该服务,但从JavaScript调用时,我现在得到另一个错误:无法加载资源:服务器响应状态为400(错误请求) – user2930100
您可以发布您的服务代码和JavaScript调用? – Saranya
我做了更多的操作,并将svc转换为asmx,所有OperationContracts被更改为webmethods,并启用了[System.Web.Script.Services.ScriptService],并且它工作正常。我不得不将JavaScript更改为GISAlloc.Services.GISService.GetGISList(shownav,null,null); – user2930100