I have the following snippet
if (hasRegistrations)
{
RedirectToAction("Manage");
}
return View();
Even thought RedirectToAction is executed, the execution still flows to return View();
How should this be handled correctly?
You need to return RedirectToAction("Manage");
Explanation:
The RedirectToAction method returns RedirectToRouteResult rather than immediately returning a HTTP redirect response. So you have to return the RedirectToRouteResult from the controller action. In your example execution is continuing and return View() is being run instead.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With