I have a Login action method in my AccountController in asp.net MVC 3 application which redirects to Relogin If login fails like this:
return RedirectToAction("ReLogin", model);
and here is Relogin action method
public ActionResult ReLogin(LogOnModel model)
{
if (!string.IsNullOrWhiteSpace(model.ErrorMessage))
ModelState.AddModelError("", model.ErrorMessage);
return View(model);
}
If I enter wrong username and password, it appears in browser address bar. How can I make it post request so that it doesn’t appear in address bar ?
Instead of using a rederict passing the model which will generate a GEt call with all the parameters, You should think of saving the model in the session and then redirect to Relogin without parameters. Then you get the model from the session.