So here's the code that's running:
return RedirectToAction("BadFileError", "Error");
https://localhost:44340/Error/BadFileError
Your browser will make a request to yourSite/Error/BadFileError
and aspnet mvc framework will not directly serve the razor file.
You need to have an action method with that name in your ErrorController
. The request will be directed to the action method, not to the view file. Your action method can return that view (or any other view)
Add this to the ErrorController.
public ActionResult BadFileError()
{
return View();
}
Also, If you simply want to show the error view content to the user, you can do that with the View()
method call with the full path to your error view. You do not necessarily need to do a redirect(which will issue a new http request).
So instead of the redirect, you can do
return View("~/Views/Error/BadFileError.cshtml");