.Net && Beyond

October 5, 2011

As you know you can’t make an Ajax cross domain request. The browser block this kind of requests. To enable Cross-Origin Requests (CORS) you need to add some headers to the server response: “Access-Control-Allow-Origin” and “Access-Control-Allow-Methods”.

If adding headers with the statement filterContext.Headers.Add(“Header”, “Value”) is not supported (throws a PlatformNotSupportedException) you can set the headers like this
filterContext.HttpContext.Response.AddHeader(“Header”, “Value”);