IE9 表单身份验证

发布于 2024-10-22 17:55:57 字数 1295 浏览 2 评论 0原文

我今天设置了 IE9,但 FormsAuthentication 停止工作。 我的步骤 - 在 Visual Studio 2010 中创建 ASP.NET MVC2 应用程序,向 HomeController 添加 Authorize 属性,打开 AccontController 并注释第 44、56、58 行。按 F5 输入用户/用户并按 ENTER,IE9 不会向 HomeController 发送身份验证 cookie

    [HandleError, Authorize]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View();
        }
    }

    [HttpPost]
    public ActionResult LogOn(LogOnModel model, string returnUrl)
    {
    if (ModelState.IsValid)
    {
            //if (MembershipService.ValidateUser(model.UserName, model.Password))
            {
                FormsService.SignIn(model.UserName, model.RememberMe);
                if (!String.IsNullOrEmpty(returnUrl))
                {
                    return Redirect(returnUrl);
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            //else
            {
                //ModelState.AddModelError("", "The user name or password provided is incorrect.");
            }
        }

        // If we got this far, something failed, redisplay form
        return View(model);
    }

I had setup IE9 today and my FormsAuthentication stoped working.
My steps - create ASP.NET MVC2 Application in Visual Studio 2010, add Authorize attribute to HomeController, open AccontController and comment lines 44, 56, 58. Hit F5 enter user/user and hit ENTER, IE9 does not send authentication cookie to HomeController

    [HandleError, Authorize]
    public class HomeController : Controller
    {
        public ActionResult Index()
        {
            ViewData["Message"] = "Welcome to ASP.NET MVC!";

            return View();
        }
    }

    [HttpPost]
    public ActionResult LogOn(LogOnModel model, string returnUrl)
    {
    if (ModelState.IsValid)
    {
            //if (MembershipService.ValidateUser(model.UserName, model.Password))
            {
                FormsService.SignIn(model.UserName, model.RememberMe);
                if (!String.IsNullOrEmpty(returnUrl))
                {
                    return Redirect(returnUrl);
                }
                else
                {
                    return RedirectToAction("Index", "Home");
                }
            }
            //else
            {
                //ModelState.AddModelError("", "The user name or password provided is incorrect.");
            }
        }

        // If we got this far, something failed, redisplay form
        return View(model);
    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

静赏你的温柔 2024-10-29 17:55:57

无法重现。对我来说效果很好。您的设置一定还有其他问题。您是否验证过 cookie 是否已启用?

Unable to reproduce. Works perfectly fine for me. There must be some other problem with your setup. Did you verify if cookies were enabled?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文