Asp.net mvc 4 ';记住我';选项不起作用

Asp.net mvc 4 ';记住我';选项不起作用,asp.net-mvc-4,cookies,custom-authentication,Asp.net Mvc 4,Cookies,Custom Authentication,我正在使用asp.net mvc4。在我的登录页面中,我保留了“记住我”选项。但看起来它不起作用了 我保存了我的authcookie,如下所示: var authTicket = new FormsAuthenticationTicket(1, //version userName, // user name DateTime.Now, //creation

我正在使用asp.net mvc4。在我的登录页面中,我保留了“记住我”选项。但看起来它不起作用了

我保存了我的authcookie,如下所示:

var authTicket = new FormsAuthenticationTicket(1, //version
                            userName, // user name
                            DateTime.Now,             //creation
                            DateTime.Now.AddMinutes(60), //Expiration
                            persistanceFlag, //Persistent
                            usrData); //Saving user data

var encTicket = FormsAuthentication.Encrypt(authTicket);
var cookie = new HttpCookie(FormsAuthentication.FormsCookieName, encTicket);
Response.Cookies.Add(cookie);
我正在使用表单身份验证。我已经在CustomAuthorizeAttribute类中检查了身份验证,该类实现了“AuthorizeAttribute”接口

public class CustomAuthorize : AuthorizeAttribute
{
    public override void OnAuthorization(AuthorizationContext filterContext)
    {
        base.OnAuthorization(filterContext);

        if (!filterContext.HttpContext.User.Identity.IsAuthenticated)
        {
            // auth failed, redirect to login page

            filterContext.Result = new RedirectResult("~/Security/UserAccount/SignIn");
        }
    }
}

但我的过程好像没有处理“记住我”选项。当我登录时,选择“记住我”选项,然后关闭并重新打开浏览器,它会再次要求登录。

如果persistanceFlag,则该值应为true


这是否正在改变?

是当选择“记住我”选项时,该值为真。我查过了。