我正在创建一个MVC应用程序,其中我有一个登录屏幕。当用户成功登录时,他能够看到他/她的主屏幕。此时如果我在另一个浏览器中打开URL,用户已经登录。我想要的是,登录屏幕应该在不同浏览器的开放网址上出现。转到登录屏幕浏览器更改
这是我的LoginController指数法:
[AllowAnonymous]
public ActionResult Index()
{
return View();
}
这是登录功能:
[HttpPost]
[AllowAnonymous]
public ActionResult LogIn(string email, string password)
{
}
在web.config中,我有以下:
<authentication mode="Forms">
<forms loginUrl="~/Login/LogIn" timeout="2880" />
</authentication>
会发生什么事,如果你打开一个不同的浏览器?即如果您使用Google Chrome,请在Firefox或Internet Explorer中打开该网站。 –
把它放在你的_Layout.cshtml中,看看你是否真的登录过。“@ User.Identity.Name”。这将输出用户的用户名,如果您没有看到用户名,那么您没有登录,并且导致一些混淆的身份验证属性有问题。 –