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

noo*_*oob 6 c# cookies asp.net-mvc owin asp.net-identity

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
Run Code Online (Sandbox Code Playgroud)

所以我尝试使用HttpContext.Request.Cookies["cookieName"].Value但它不起作用。事实上,当我执行 a 时HttpContext.Response.Cookies.Count,它返回 0。

tra*_*max 0

身份验证管理器此时不会设置 cookie。它仅使用应写入 cookie 的身份对象设置回调。因此SignIn该方法仅将值存储在内存中,直到实际发送出响应为止。我最近确实写过这个

无论如何,即使您获得了 cookie 的值,它也是由 OWIN 加密的,更改它的值很可能会使 cookie 失效。

你想用 cookie 做什么?