Cross-site ajax call to a WCF Service

前端 未结 4 1464
陌清茗
陌清茗 2021-02-06 18:09

Is it possible to do a cross-site call, in Javascript, to a WCF service?

I don\'t mind if it\'s a POST or a GET.

But I\'ve heard that these days, browsers don\'t

4条回答
  •  终归单人心
    2021-02-06 18:22

    New W3C recommendations are being standardised to allow cross-site requests between trusted parties via the Access Control for Cross-Site Requests specification.

    This requires a server serving suitable Access Control HTTP headers and a browser capable of understanding and acting upon such headers.

    In short, if a remote host says it likes your domain, and a browser understands what this means, you can perform xmlHttpRequests against that host regardless of the same origin policy.

    Currently very few browsers support this functionality. IE8 apparently does (I haven't tested it) and Firefox 3.1 does (I have tested this extensively). I expect other browsers to follow suit quite quickly.

    You shouldn't expect sufficient adoption of compatible browsers until 2012 at the earliest.

    That's the ultimate solution to the problem. The downside is waiting a few years before it can be used in mainstream applications.

    If this is for use within an environment you fully control, such as for an intranet where you can determine which browser is used and where you can configure multiple servers to issue the correct headers, it works perfectly.

提交回复
热议问题