C# 重置身份验证cookie

C# 重置身份验证cookie,c#,asp.net,identity,C#,Asp.net,Identity,我有一个登录页面,当经过身份验证的用户在经过身份验证后返回此页面时,我希望他们重新验证自己。现在,这就是我所拥有的: protected void Page_Init(object sender, EventArgs e) { HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache); if (User.Identity.IsAuthenticated) {

我有一个登录页面,当经过身份验证的用户在经过身份验证后返回此页面时,我希望他们重新验证自己。现在,这就是我所拥有的:

protected void Page_Init(object sender, EventArgs e)
{
    HttpContext.Current.Response.Cache.SetCacheability(HttpCacheability.NoCache);

    if (User.Identity.IsAuthenticated)
    {
        var authenticationManager = HttpContext.Current.GetOwinContext().Authentication;
        authenticationManager.SignOut();
    }
}
如何清除身份验证cookie并设置新cookie?我正在使用身份验证


谢谢。

要删除cookie,请将其过期日期设置为过去的某个时间。如果要替换cookie,只需存储具有相同名称的新cookie