无法访问WCF 4.0 REST跨域

时间:2014-08-09 10:14:11

标签: wcf

我试图用以下几点来描述我的问题:

1.使用GET&amp ;;处理WCF 4.0 REST服务POST方法选择'CountryList'和Add New Country到数据库。使用的实体框架。

2.将此服务作为IIS 7中“默认网站”下的应用程序部署。

3.Created客户端应用程序(类似于ANDROID应用程序)具有 .html页面,jQueries,'MyHandler:IHttpHandler'。

MyHandler:IHttpHandler - 正在使用'WebClient','DataContractJsonSerializer'等类来插入数据。

例如:

byte [] res1 = WC.UploadData(ServiceUrl +“NewCountry”,“POST”,MS.ToArray());

4.此客户端应用程序在Visual Studio 2010调试模式下运行良好,但是当我在IIS 7中发布并部署(作为“默认网站”下的另一个应用程序)时,它显示在

的Fiddler:

'HTTP 404.您正在查找的资源(或其中一个依赖项)可能已被删除,名称已更改或暂时不可用。请查看以下网址,并确保拼写正确。'

我已多次检查路径,这是正确的。

请帮助,

提前致谢

1 个答案:

答案 0 :(得分:1)

请参阅此链接Cross Domain jQuery Ajax Request & WCF REST Service

解决方案在您的配置中设置:

<standardEndpoints>
      <webScriptEndpoint>
       <standardEndpoint crossDomainScriptAccessEnabled="true">
       </standardEndpoint>
      </webScriptEndpoint>
      </standardEndpoints>
  <bindings>
  <webHttpBinding>
    <binding name="webHttpBindingWithJsonP"
             crossDomainScriptAccessEnabled="true" />
  </webHttpBinding>
相关问题