IE9 表单身份验证
我今天设置了 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
无法重现。对我来说效果很好。您的设置一定还有其他问题。您是否验证过 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?