Reputation: 11125
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 ?
Upvotes: 2
Views: 4881
Reputation: 32768
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();
}
Upvotes: 7
Reputation: 20674
Try this:
return RedirectToAction("Index", "User", new { returnUrl, errorMessage, etc });
Upvotes: 0