Browser cross domain example -

Posted in ASP.NET, on 9/6/2015

Simple example of how to achieve cross domain access at, following example is the simple and lazy way which just make it working by modify web.config.

let's assume you have following  two site, is trying to access's ajax api, /api/getMyData

    • contains /api/getMyData

So, what's you have to do at site is following, you're let your server to return Access-Control-Allow-Origin header to the http response. 

        <add name="Access-Control-Allow-Origin" value=""/>
  </system.webServer> site you can just call as following, assume your api is

$.ajax({ url: "" }).then(function () {
  "done with call's api");

for more detail information about how to enable cross for specific http method, specific site, or other usefull library. I'll add reference at here or code example.


Enabling Cross-Origin Requests in ASP.NET Web API 2