I have a WCF service that I access fram Javascript using AJAX and JSON. The client and the service is on the same site (domanin). It works great.
我有一个WCF服务,我使用AJAX和JSON访问fram Javascript。客户端和服务位于同一站点(domanin)。它的工作原理。
I now need to call the same service from several other sites/domains. How is this done? So far I have not found any resources describing this scenario.
我现在需要从其他几个站点/域调用相同的服务。这是怎么做的?到目前为止,我还没有找到任何描述此场景的资源。
These sites uses ASP.NET 4.0 (C#).
这些网站使用ASP。NET 4.0(c#)。
2 个解决方案
#1
2
I agree that you need JSONP but I don't agree with using custom behavior from WCF 3.5 samples. WCF 4 has a native support for JSONP by turning on crossDomainScriptAccessEnabled
in the webHttpBinding
configuration. I wrote an example in this question.
我同意您需要JSONP,但我不同意使用WCF 3.5示例中的自定义行为。WCF 4通过在webHttpBinding配置中打开启用了crossDomainScriptAccessEnabled来支持JSONP。我在这个问题中写了一个例子。
#1
2
I agree that you need JSONP but I don't agree with using custom behavior from WCF 3.5 samples. WCF 4 has a native support for JSONP by turning on crossDomainScriptAccessEnabled
in the webHttpBinding
configuration. I wrote an example in this question.
我同意您需要JSONP,但我不同意使用WCF 3.5示例中的自定义行为。WCF 4通过在webHttpBinding配置中打开启用了crossDomainScriptAccessEnabled来支持JSONP。我在这个问题中写了一个例子。