如何在调用IauthenticationManager.SignIn后立即获取OWIN cookie的值?

时间:2014-09-05 15:27:03

标签: c# asp.net-mvc cookies asp.net-identity owin

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。

1 个答案:

答案 0 :(得分:0)

身份验证管理器不会在此时设置cookie。它只使用应写入cookie的标识对象设置回调。因此SignIn方法仅在内存中存储值,直到实际发送响应为止。我做了write about this recently

无论如何,即使你获得了cookie的价值,它也会被OWIN加密,并且更改它的值很可能会使cookie失效。

你想用cookie做什么?