I am trying to serve a custom error page in an MVC2 app, which uses the ELMAH for error log (elmah)
I can’t seem to reference the page correctly.
The error page is located at ~/Views/Shared/Error.aspx
In the web.config :
<system.web>
<customErrors mode="On" defaultRedirect="~/Shared/Error.aspx"/>
</system.web>
But when I cause an error, expecting the error page, I get:
The resource cannot be found.
Requested URL: /Shared/Error.aspx
smae result even if I modify defaultRedirect to ~/Views/Shared/Error.aspx
What am I doing wrong ?
edit: I obviously don’t want to redirect to an action. I just want to display a static generic error page.
You should set
defaultRedirectto the path of a route that renders your error page, e.g.Or a static HTML error page, e.g.