Enable cross origin request with ASP.NET MVC

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”. So I made a MVC filter that will allow cross domain calls: public class AllowCrossDomain : ActionFilterAttribute { public const string AllDomains = "*";   private readonly string _allowMethods; ...
tags: , , ,
7 comments