首页 > 解决方案 > 方法“登录”没有重载需要 4 个参数

问题描述

我在我的AccountModels. 我还添加了一个属性角色(下拉列表的值为“Admin”和“User”)。现在它显示一些错误

方法“登录”没有重载需要 4 个参数

[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginModel model, string returnUrl)
{
    if (ModelState.IsValid && 
        WebSecurity.Login(model.UserName, 
                          model.Password,
                          model.Role, 
                          persistCookie: model.RememberMe))
    {
        return RedirectToLocal(returnUrl);
    }
}

我该如何解决这个问题?

标签: c#asp.net-mvc

解决方案


登录的语法是WebSecurity.Login(userName, password, persistCookie). 您正在尝试传递 4 个参数


推荐阅读