Catch all ASP.NET exceptions, log and show an Orchard error page

Topics: Writing modules
Sep 5, 2013 at 3:46 PM
Quite often my site will show the ASP.NET YSOD exception screen - user tries to upload a large file to Media, enters "<" in a form field, etc. How can I catch all these exceptions, log them and display an error screen inside Orchard - with menus, user name, etc. ?
Sep 5, 2013 at 7:37 PM
This may help answering the first case (request limit): http://stackoverflow.com/questions/665453/catching-maximum-request-length-exceeded.
This may help answering the second case (user enters "<"): http://www.justskins.com/forums/howto-catch-httprequestvalidationexception-myself-7325.html.
Sep 10, 2013 at 2:39 PM
Edited Sep 10, 2013 at 2:40 PM
Thanks Mr Schoorstra.

I've created "private void Application_Error(object sender, EventArgs e)" in Orchard.Web/Global.asax.cs, but in never gets hit. Any redirects inside have no effect and VS debugger never shows that method executing. Any idea what I'm doing wrong?