栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 面试经验 > 面试问答

如何为现有WCF服务本地启用JSONP?

面试问答 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

如何为现有WCF服务本地启用JSONP?

更新您的配置,如下所示:

<configuration>  <system.web>    <compilation debug="true" targetframework="4.0">    <authentication mode="None">  </authentication></compilation></system.web>  <system.webserver>    <modules runallmanagedmodulesforallrequests="true">  </modules></system.webserver>  <system.servicemodel>    <servicehostingenvironment **aspnetcompatibilityenabled**="true">    <standardendpoints>      <webscriptendpoint>        <standardendpoint **crossdomainscriptaccessenabled**="true" name="">      </standardendpoint></webscriptendpoint>    </standardendpoints>  </servicehostingenvironment></system.servicemodel></configuration>

请参阅此处的博客文章,其中提供了创建可跨域访问的wcf服务的演练。

这将使您的服务能够接受来自跨域来源的请求。

在确定是否填充您的响应(jsonp中的p)方面,

感谢@carlosfigueira:

如果使用.Net 4,则JSONP本身受支持。只要请求具有称为“ callback”的查询字符串参数(可以配置此名称),则将使用函数名称填充响应。

否则,您将需要编写一个自定义消息检查器来适当填充响应。



转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/609129.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号