
CodePudding user response:
Expected that you had defined @model
at the top of your page which the page is expected to receive that type of object.
@model YourProject.Models.LoginModel
And make sure that you have returned an instance of the model to pass to your view. Otherwise, the @model
will be null
.
public ActionResult Login()
{
var model = new LoginModel();
return View(model);
}
[HttpPost]
public ActionResult Login(LoginModel model)
{
return View(model);
}
References
Strongly typed models and the @model directive