Best way to handle Cross Domain on SharePoint Intranet w/o server side, silverlight, DBC etc

前端 未结 2 1863
半阙折子戏
半阙折子戏 2021-02-04 17:36

I\'m working on a Microsoft internal SharePoint site, and I need to pull in List data from a cross domain SharePoint site.

I don\'t want to use Silverlight, for various

2条回答
  •  闹比i
    闹比i (楼主)
    2021-02-04 17:55

    "Simple?" Not exactly. Given your requirements, particularly "w/o server side," this isn't possible.

    However, if you can forego that requirement, you have a few options for enabling cross-domain requests.

    CORS

    There's decent support for Cross-Origin Resource Sharing for XMLHttpRequest and Microsoft's XDomainRequest. Though, this will require that the remote server include the proper headers in the response to allow your origin/domain to make the request.

    <% Response.AddHeader("Access-Control-Allow-Origin", "*") %>
    

    JSONP

    A common option is JSONP, which loads the resource in a loadResource( [ {"id": 1, "name": "foo"}, {"id": 2, "name": "bar"} ] );

    Server-side Proxy

    If the remote server you're requesting from can't (or won't) be adjusted to support cross-domain requests, you're pretty much left with making a Server-Side Proxy on your server.

    The general pattern is described at AjaxPatters.org and a number of .NET implementations can be found, including John Chapman's and the Cross-Domain Proxy project.

提交回复
热议问题