大家好,
我在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:SC1.contoso/.
Site Collection 1 : SC1.contoso/ .
网站集2:SC2.contoso/
Site Collection 2: SC2.contoso/
网站集3:SC3.contoso/
Site Collection 3: SC3.contoso/
链接列表在网站集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="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>更多信息:
解决跨域Ajax调用SharePoint REST服务的问题 在Chrome中
Fixing issue in making cross domain Ajax call to SharePoint REST service in Chrome
谢谢
最好的问候
更多推荐
在Chrome中使用REST API在母版页上进行跨域调用时遇到问题
发布评论