在Chrome中使用REST API在母版页上进行跨域调用时遇到问题 [英] Problem with Cross Domain calls on Master Page with REST API in Chrome

查看:70
本文介绍了在Chrome中使用REST API在母版页上进行跨域调用时遇到问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我在chrome浏览器上遇到SharePoint跨域调用的问题.

I'm struggling with SharePoint cross domain calls on chrome browser.

我的要求:从SharePoint列表数据中读取URL和描述,并在母版页上靠近西装栏链接的位置显示链接.我的网站集的主机名如下所述.

My Requirement: Reading URLs and Description from a SharePoint list data and show the links on master page near suit bar links. My site collections are host named as mentioned below.

网站集1:http://SC1.contoso.com/.

Site Collection 1 : http://SC1.contoso.com/ .

网站集2:http://SC2.contoso.com/

Site Collection 2: http://SC2.contoso.com/

网站集3:http://SC3.contoso.com/

Site Collection 3: http://SC3.contoso.com/

链接列表在网站集1上.

The links list is on Site Collection 1.

我建立了一个自定义的javascript文件.使用REST API调用,我获得了URL&然后创建HTML并将其绑定到母版页上的DIV的说明.这在IE上工作正常.但是,当我在chrome中尝试时,我无法从Site进行REST调用 集合2和3.好像chrome阻止了对网站集1的跨域调用.

I build a custom javascript file. Using REST API call i'm getting the URL & Description then building the html and binding it to the DIV on master page. This is working fine on IE. However when i tried it in chrome i'm not able to do REST call from Site collection 2 & 3. Looks like chrome is blocking the cross domain calls to Site Collection 1.

我尝试过ajax调用& SP.RequestExecutor没有运气.

I tried ajax call & SP.RequestExecutor without any luck. 


我还尝试了在IIS上进行URL重写的解决方案,这导致文档签出/签入问题.所以我正在寻找替代解决方案.

I also tried URL rewriting solution on IIS, which causing document check out/in issue. So i'm looking alternative solutions.

请帮助.

感谢阅读

推荐答案

请在SharePoint Web应用程序web.config中添加httpPortal设置:

Please add the httpPortal Settings in SharePoint web application web.config:

<httpProtocol>
      <customHeaders>
        <add name="Access-Control-Allow-Origin" value="http://SiteUrl" />
        <add name="Access-Control-Allow-Headers" value="Content-Type,Accept,X-FORMS_BASED_AUTH_ACCEPTED,crossDomain,credentials " />
        <add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
        <add name="Access-Control-Allow-Credentials" value="true" />
      </customHeaders>
</httpProtocol>

更多信息:

Fixing issue in making cross domain Ajax call to SharePoint REST service in Chrome

谢谢

最好的问候


这篇关于在Chrome中使用REST API在母版页上进行跨域调用时遇到问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆