title: ASP.NET MVC 4 cookie disappears
body: <p>I have an ASP.NET application that sends an authentication cookie to an ASP.NET MVC application, used as an back office application.</p>
  
  <p>I've added a global filter that checks every controller action for the authentication cookie. If the cookie exists, it allows the user to enter the page.</p>
  
  <p>The code looks like this:</p>
  
  <pre><code> public class SecurityFilter : FilterAttribute, IAuthorizationFilter
      {
          public void OnAuthorization(AuthorizationContext filterContext)
          {
              // TODO: For some reason .AUTHCookie cookie isn't exist in request context of filter,
  
                             HttpCookie cookie = filterContext.RequestContext.HttpContext.Request.Cookies[".AUTHCookie "];
  
  
              if (cookie != null)                 {
  </code></pre>
  
  <p>From the other side I can see the cookie sent from the ASP.NET application in <code>Application_BeginRequest</code> event in the Global.asax file.</p>
  
  <p>Where and why the cookie disappeared? In what part of the MVC Request-Handling pipeline was the cookie thrown away?</p>
  
  <pre><code>  protected void Application_BeginRequest(object sender, EventArgs e)
          {
              var cookies = HttpContext.Current.Request.Cookies;
              // HERE I CAN SEE BOTH cookies. In filter action only one cookie was found. The authentication cookie is thrown somewhere ...
          }  
  </code></pre>