ClaimsIdentity ident = await UserManager.CreateIdentityAsync(user, DefaultAuthenticationTypes.ApplicationCookie);
AuthManager.SignOut();
AuthManager.SignIn(new AuthenticationProperties { IsPersistent = userInfo.rememberMe }, ident);
//I would like to get the value here
所以我尝试使用HttpContext.Request.Cookies["cookieName"].Value
,但它不起作用。事实上,当我做HttpContext.Response.Cookies.Count
时,它返回0。
答案 0 :(得分:0)
身份验证管理器不会在此时设置cookie。它只使用应写入cookie的标识对象设置回调。因此SignIn
方法仅在内存中存储值,直到实际发送响应为止。我做了write about this recently。
无论如何,即使你获得了cookie的价值,它也会被OWIN加密,并且更改它的值很可能会使cookie失效。
你想用cookie做什么?