在Chrome中使用REST API在母版页上进行跨域调用时遇到问题

编程入门 行业动态 更新时间:2024-10-10 19:21:48
本文介绍了在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: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在母版页上进行跨域调用时遇到问题

本文发布于:2023-11-28 12:45:44,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1642455.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:母版   Chrome   REST   API

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!