title: ASP.NET MVC - use authorize attribute
body: <p>I have a ASP.NET MVC website.</p>
  
  <p>I don't really manage users, but I do a login to an external API and then I store a <code>"ASPXFORMSAUTH"</code> cookie.</p>
  
  <p>It's a WCF service. In my controller, I call :</p>
  
  <pre><code>MyWcfServiceClient.Login()
  </code></pre>
  
  <p>In the AfterReceiveReply, I store the response of the service in a variable :</p>
  
  <pre><code>cookie = httpResponse.Headers[HttpResponseHeader.SetCookie];
  </code></pre>
  
  <p>Then In the controller, I get this cookie and store it using :</p>
  
  <pre><code>Response.Cookies.Add(cookie);
  </code></pre>
  
  <p>I'm a beginner with ASP.NET MVC, but can I use the <code>[Authorize]</code> attribute to allow the access to the controllers methods only if the request contains this cookie ? And <code>[AllowAnonymous]</code> on the methods before the API login.</p>
  
  <p><strong>EDIT :</strong></p>
  
  <p>So it should work just adding the <code>[Authorize]</code> attribute ?</p>
  
  <p>I'm calling the controller method using ajax, and the value of <code>Request.Headers["Cookie"]</code> is <code>.ASPXAUTH=1D415AF723......</code></p>
  
  <p>But I get the ajax error callback...</p>
  
  <p>Am I missing something ?</p>