huy cao
huy cao

Reputation: 28

How can i bypass CORS Policy with ASP.NET and Ajax?

I want to bypass CORS Policy to GET data XML from another domain. I try so much but have no luck. There are:

For you, JSONP is faster or Proxy is Faster ?

Thanks for watching ?

Upvotes: 0

Views: 1700

Answers (1)

David L
David L

Reputation: 33815

If the other domain does not explicitly trust you, you cannot invoke it from the client via AJAX for security reasons unless you use JSONP.

However, you can only use JSONP as long as you are sticking to only GET requests and the server knows how to respond with a JSONP-formatted response.

On the other hand, if they DO explicitly trust you, you have a few options.

  • CORS support on the server as long as you are using modern browsers (IE9 still has issues with this) with the appropriate headers.
  • XDomain, which is essentially a javascript proxy shim. However, this also requires explicit request domain inclusion.

On the other hand, if you create a proxy server-side on your end that can call across to the other domain, you'll have no issues whatsoever.

A server-side proxy should in theory always be slower than ajax options since you are making two calls instead of one.

Upvotes: 1

Related Questions