-1

This question has probably been answered before but I haven't been able to find a suitable answer.

I'm using asp.net web forms and am wanting to make a jquery Ajax request from one site on a particular domain to another site on another domain. The Ajax request is to a web method on an aspx page.

As expected I am having problems with CORS. My question is are you able to make an Ajax call to a web method on an aspx page from a different domain? If so any advice or links to resources would be very grateful.

Thanks David

David
  • 209
  • 4
  • 17

2 Answers2

0

As a security measure, AJAX does not allow you to make requests to other domains.

KaMZaTa
  • 535
  • 2
  • 9
  • 24
0

You've got several options. First, you can use CORS (http://enable-cors.org/) but only if you've got access to the application on the target server.

Alternatively, you can use JSONP (but again, the server must support it): http://www.sitepoint.com/jsonp-examples/.

The last thing that comes into my mind would be using your server as a proxy: call a web service on your server which calls the remote server. This should work as server-to-server communication is not restricted by same origin policy (it's a browser feature).

Also, take a look at this thread: How to make cross domain request

Community
  • 1
  • 1
Michał Dudak
  • 4,923
  • 2
  • 21
  • 28