I'm trying to add a 500 error handling page to my ASP.NET MVC3 project.
I want my custom error page displayed regardless of local or remote access. My website is running on IIS6,IIS7 & IIS7.5 Express
I want it displayed when:
- An exception is thrown in Application_BeginRequest
- An exception is thrown in Application_Error
- An exception is thrown in a static constructor in the Website Project
- An exception is thrown in a Controller
- An exception is thrown in a view
- An exception thrown anywhere pretty much.
I haven't been able to do in this, in fact I haven't been able to get any custom error pages to display at all.
My error page lives in ~/Views/Shared/Error.aspx
My Application_Error method in Global.asax.cs just logs the thrown exception.
My web.config has this:
<customErrors mode="On" defaultRedirect="~/Views/Shared/Error.aspx" redirectMode="ResponseRewrite">
</customErrors>
...
<system.webServer>
<httpErrors errorMode="Custom" />
...
</system.webServer>
What am I missing? What do I need to do to handle these scenarios?