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。 最佳答案
身份验证管理器此时未设置cookie。它仅使用应写入cookie的标识对象设置一个回调。因此,SignIn
方法仅将值存储在内存中,直到实际发送响应为止。我做了write about this recently。
无论如何,即使获得cookie的值,OWIN也会对其进行加密,并且更改其值很可能会使cookie失效。
您要如何处理Cookie?
关于c# - 调用IauthenticationManager.SignIn后,如何立即获取OWIN cookie的值?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25689248/