Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/328.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 表单身份验证asp.net mvc未进行身份验证_C#_Asp.net Mvc 5_Forms Authentication - Fatal编程技术网

C# 表单身份验证asp.net mvc未进行身份验证

C# 表单身份验证asp.net mvc未进行身份验证,c#,asp.net-mvc-5,forms-authentication,C#,Asp.net Mvc 5,Forms Authentication,当我尝试登录时,FormsAuthentication不起作用。它成功登录并保存会话。将我重定向到索引视图后,@FormsAuthentication.IsEnabled的值为false [HttpPost] public ActionResult Login(Models.User user) { if (IsValid(user.Username, user.Password)) {

当我尝试登录时,FormsAuthentication不起作用。它成功登录并保存会话。将我重定向到索引视图后,@FormsAuthentication.IsEnabled的值为false

     [HttpPost]
     public ActionResult Login(Models.User user)
        {
            if (IsValid(user.Username, user.Password))
            {
                FormsAuthentication.SetAuthCookie(user.Username, false);
                Session["Username"] = user.Username;
                Session["IP"] = user.IPAddress;
                return RedirectToAction("Index", "Users");
            }
            else
            {
                ModelState.AddModelError("", "Login Details are wrong!");
            }
            return View();
        }

您正在使用的浏览器的名称/版本是什么

如果您正在使用IE11,下面的链接可能会很有用

web.config中的身份验证模式必须是FormsAuthentication属性的Forms。如果启用,则返回true。下面是dotpeek的反编译代码

public static bool IsEnabled
{
  get
  {
    return AuthenticationConfig.Mode == AuthenticationMode.Forms;
  }
}

您的模板最初是否使用asp.net标识?如果是这样,它会删除FormsAuthenticationModule,在web.config中查找并取出它。