Inside my Index action I call my NotFound Action. I follow in debug and the if condition tests true, it goes to the “return RedirectToAction(“NotFound”);” statement, it then goes to Dispose and then returns to the Index Action not the NotFound Action. If I Redirect to the Details Action it works fine. These are all in the same controller. The NotFound View just contains text.
if (condition tests true) { return RedirectToAction("NotFound"); }
public ActionResult NotFound()
{ return View(); }
I’ve also tried the NotFound as a ViewResult. It still fails.
You can return the
NotFoundView directly from your Index actionThis will work as long as there is a view named “NotFound.cshtml”