I've ASP.NET MVC5 project with standard auth process.
/Account/Login I've got response with new cookie
.AspNet.ApplicationCookie with auth token. The question is how to get this token in Login action, right after it's generated?
My only idea is to try obtain it from response's cookie but it doesn't work:
// ... somwhere in login action
// <-- How to obtain auth token here? Code below don't work
var token = HttpContext.Current.GetOwinContext().Response.Cookies[".AspNet.ApplicationCookie"];
.. but this is not even compiling.
Not sure if there is a leading period "." though, also try:
On callback action from OAuth you could use Request.Cookies[".AspNet.ExternalCookie"]
I believe you may be confusing Request and Response. Response is what you send TO the client - so you never want to read a cookie from there. Instead, read the cookie from the Request object.
If you "read" from the Response object and the cookie doesn't' already exist in it, it will simply create a NEW cookie of that name - with no value!