I realize this is probably simple but all my attempts/research has come up empty.
I've got the following in my view
@if (Model.HasError)
{
<div class="alert alert-danger" role="alert">
Username or password is incorrect
</div>
}
and my controller looks more or less like
public ActionResult Login(User model)
{
model.HasError = true;
return View(model);
}
This produces the desired result and the message displays. However, the url is also populated with all the values from the model as well. I really just want the HasError property of the model to show.
Is there a better way to go about doing this? I looked at having two different models but it seemed like a lot to just hide/show an element....
@Url.Action("Login", model)- since OP wants to have single model for action and view all fields of the model will endup in the url (probably including plain text password to make it even more ridiculous).