In my ASP.NET MVC project I have the /errors/error.html page as a general error page and a second /errors/error404.aspx that handles the 404 errors.
<customErrors mode="On" redirectMode="ResponseRewrite" defaultRedirect="/errors/error.html">
<error statusCode="404" redirect="/errors/error404.aspx" />
</customErrors>
Also, I have in my Global.asax file a general handler that logs all uncaught exceptions for logging purposes.
public void Application_Error(object sender, EventArgs e)
{
Exception ex = Server.GetLastError();
Common.Core.LogError(ex); // Saving exception details in the database
}
The above setup works well except for when I have a general error (e.g. a 500 error) the Application_Error logs this error below:
The view 'Error' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Views/app/Error.aspx
~/Views/app/Error.ascx
~/Views/Shared/Error.aspx
~/Views/Shared/Error.ascx
~/Views/app/Error.cshtml
~/Views/app/Error.vbhtml
~/Views/Shared/Error.cshtml
~/Views/Shared/Error.vbhtml
The Exception from the actual error is not logged at all.
How can I avoid this error?
P.S. For anyone who might ask, I tried to put my error pages as views inside a controller but also I couldn't make it work with the redirectMode="ResponseRewrite" option.