Reputation:
If condition is true then redirect else return the current view. This is what I am intending to do but I got the first part only not the 2nd such as returning a view, because if I put return to view in else part then ActionResult throws an error because it needs something to return.
public ActionResult Authenticate(Users u)
{
if (basicOps.getUsersLogin(u.UserName, u.Password))
{
RedirectToAction("GetImagesStories", "Stories");
}
return View("Authenticate");
}
this way I can't redirect because it always executes the return part but I want it to run only if IF condition fails.
Upvotes: 1
Views: 477
Reputation: 236268
You forgot to return RedirectToAction
action result:
public ActionResult Authenticate(Users u)
{
if (basicOps.getUsersLogin(u.UserName, u.Password))
{
return RedirectToAction("GetImagesStories", "Stories");
}
return View("Authenticate");
}
Upvotes: 1