I want to show a custom page if the user tries to go a controller that does not exist. I've tried the method where you have to create the page you want to show in case of an error and turn on custom errors. But for some reason it doesn't work. This is what I've tried so far.
Web.config
<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="~/Views/Shared/Error/">
<error statusCode="404" redirect="~/Views/Shared/Error/Index/" />
</customErrors>
<httpErrors errorMode="DetailedLocalOnly">
<remove statusCode="404"/>
<error statusCode="404" path="~/Views/Shared/Error.cshtml" responseMode="File"/>
</httpErrors>
ErrorController
public class ErrorController : Controller
{
//
// GET: /Error/
public ActionResult Index()
{
Response.StatusCode = 404;
Response.TrySkipIisCustomErrors = true;
return View();
}
}
Any help is appreciate it. I've searched a bunch of websites, and most explained that this is how it's done. I'm still new with this, so perhaps I'm missing the whole point.