Asp.net mvc 4 未创建MVC 4持久Cookie,它将我重定向到登录页面。(当FormsAuthentication.SetAuthCookie(用户名,persistentCookie:TRUE)

Asp.net mvc 4 未创建MVC 4持久Cookie,它将我重定向到登录页面。(当FormsAuthentication.SetAuthCookie(用户名,persistentCookie:TRUE),asp.net-mvc-4,google-chrome,cookies,persistence,forms-authentication,Asp.net Mvc 4,Google Chrome,Cookies,Persistence,Forms Authentication,控制器中的操作 [HttpPost] public ActionResult Login(Models.User user, string returnUrl) { if (ModelState.IsValid) { if (user.IsValid(user.UserName, user.Password)) { FormsAuthentication.Set

控制器中的操作

    [HttpPost]
    public ActionResult Login(Models.User user, string returnUrl)
    {
        if (ModelState.IsValid)
        {
            if (user.IsValid(user.UserName, user.Password))
            {
                FormsAuthentication.SetAuthCookie(user.UserName, user.RememberMe);
                return RedirectToLocal(returnUrl);        
            }
            else
            {
                ModelState.AddModelError("", "Login data is incorrect");
            }
        }
        return View(user);
    }
user.IsValid函数

    public bool IsValid(string _username, string _password)
    {
        bool valid = false;

        if (Membership.ValidateUser(_username, _password))
        {
            valid = Roles.IsUserInRole(_username, "Administrators");
        }

        return valid;
    }
    private ActionResult RedirectToLocal(string returnUrl)
    {
        if (Url.IsLocalUrl(returnUrl))
        {
            return Redirect(returnUrl);
        }
        else
        {
            return RedirectToAction("Index", "Practices");
        }
    }
重定向到局部功能

    public bool IsValid(string _username, string _password)
    {
        bool valid = false;

        if (Membership.ValidateUser(_username, _password))
        {
            valid = Roles.IsUserInRole(_username, "Administrators");
        }

        return valid;
    }
    private ActionResult RedirectToLocal(string returnUrl)
    {
        if (Url.IsLocalUrl(returnUrl))
        {
            return Redirect(returnUrl);
        }
        else
        {
            return RedirectToAction("Index", "Practices");
        }
    }
网络配置

    <authentication mode="Forms">
    <forms name=".PRACTICESAPPCOOKIE" defaultUrl="~/Practices/Index" loginUrl="~/Users/Login" timeout="2880" />
  </authentication>

当FormsAuthentication.SetAuthCookie在persistentCookie参数中变为FALSE时,一切正常,并创建cookie:

当persistentCookie参数为TRUE时,问题就出现了,我被重定向到我的登录页面,因为我验证了应用程序不能被未经授权的用户使用

如果我查看cookies,cookie不会被创建

值得一提的是,该应用程序在localhost中运行良好,问题出在站点上(我已经在chrome、internetexplorer和firefox中进行了测试,但只在internetexplorer中运行)

还尝试通过使用持久cookie创建身份验证票证来实现此目的,并获得了相同的结果(当持久cookie为true时重定向)

我开始认为问题出在分配应用程序的服务器上,或者是IIS的什么地方

有什么想法吗