In my web.config, I have:
<system.web>
<customErrors mode="On" defaultRedirect="Error.cshtml" />
</system.web>
In Views/Shared/Error.cshtml, I have:
@model System.Web.Mvc.HandleErrorInfo
@{
ViewBag.Title = "Error";
}
<h2>
Sorry, an error occurred while processing your request.
</h2>
If I put an invalid URL/route into my browser, I get this:
Server Error in '/' Application.
The resource cannot be found.
Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly.
Requested URL: /Error.cshtml
Why can't Error.cshtml be found? The file is definitely in Views/Shared.