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