Maintain URL after Post in asp.net MVC
.net, asp.net-mvc, asp.net-mvc-4, routes, url
Solution
Why can't you rename the `Login` action to `Index`.
public ActionResult Index()
{
return View();
}
[HttpPost]
public ActionResult Index(LoginModel model)
{
return View();
}
or
you can use `ActionName` attribute
[HttpPost, ActionName("Index")]
public ActionResult Login(LoginModel model)
{
return View();
}
Problem
Fairly new to asp.net mvc I don't have knowledge to change the way certain things work. Here is one of them Controller Action Index displays a Login page Controller Action Login with `[HttpPost]` takes the model and validates it In the case, validation fails the URL seems to be set at `http://blah_blah/Users/Login` ( which when requested causes 404 since there is no Login action on the controller) So is creating a Login action only way to solve problem or any other solutions i got ?