title: CORS not working ASP.Net MVC5
body: <p>I am trying to block cross-domain access to my resources using CORS. I have tried <code>WebApi.Cors</code> and custom <code>ActionFilter</code> too. But I am still able to access the data from not allowed domains. </p>
  
  <p><strong>My <code>ActionFilter</code> code is below</strong></p>
  
  <pre><code>public class AllowCrossSiteAttribute : ActionFilterAttribute
      {
          public override void OnActionExecuting(ActionExecutingContext filterContext)
          {
              filterContext.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Credentials", "true");
              filterContext.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Origin", "https://example.com");
              filterContext.RequestContext.HttpContext.Response.AddHeader("Access-Control-Allow-Headers", "*");
              base.OnActionExecuting(filterContext);
          }
  }
  </code></pre>
  
  <p><strong>My Controller</strong></p>
  
  <pre><code>    [HttpGet]
      [AllowCrossSite]
      public ActionResult Index(string username)
      {
        //return json data
      }
  </code></pre>
  
  <p>These headers are present in the response headers but why the request is not blocking from other domains, what am I doing wrong? Please help</p>