title: ASP.net MVC global Authorize filter forcing login on an AllowAnonymous action
body: <p><strong>Setup (using MVC 4)</strong></p>
  
  <pre><code>public class MyAuthorizeAttribute : AuthorizeAttribute {
  
      protected override bool AuthorizeCore(HttpContextBase httpContext) {
  
          var isAuthorised = base.AuthorizeCore(httpContext);
  
          if(isAuthorised) {
              // retrieve authentication ticket from cookie and
              // create custome principal and attach to 
              // httpContext.User
          }
  
          return isAuthorised;
      }
  }
  </code></pre>
  
  <p>Gloabl.asax.cs:</p>
  
  <pre><code>public static void RegisterGlobalFilters(GlobalFilterCollection filters)
  {
      filters.Add(new HandleErrorAttribute());
      filters.Add(new MyAuthorizeAttribute());
  }
  </code></pre>
  
  <p>HomeController.cs:</p>
  
  <pre><code>using System.Web.Mvc;
  
  public class HomeController : Controller
  {
      [AllowAnonymous]
      public ActionResult Index()
      {
          return View();
      }
  }
  </code></pre>
  
  <p><strong>Problem</strong></p>
  
  <p>A call to the home page forces the login page to load.</p>
  
  <p><strong>Question</strong></p>
  
  <p>When the HomeController.Index() action is decorated with [AllowAnonymous], why does ASP redirect me to the login view ?</p>
  
  <p>I am using <a href="http://weblogs.asp.net/jgalloway/archive/2012/04/18/asp-net-mvc-authentication-global-authentication-and-allow-anonymous.aspx">this</a> article for reference</p>