I've scanned various articles, and forum posts here, which show how to configure custom error pages in Umbraco. However, atfer following these, I'm still not able to get my custom error page displayed to the user when an errror occurs.
Here is how I created and configured my custom error page:
Created new document type and template named "Error". Created new content item named "Error" which uses the "Error" template. Edit the web.config file - <customErrors mode="On" /> instead of "RemoteOnly" Edit the umbracoSettings.config file like so:
To test the error page, I have manually placed a "throw new Exception()" call in a .cshtml file which the site uses. When I navigate to the page which uses this cshtml file, the error displayed to the user is:
I was expecting to see my Error.aspx page appear. I can navigate to error.aspx without any problems, but Umbraco isn't using that file when an error is raised.
Can someone suggest what I may have done wrong during the config please?
1: It should not be neccesary to set the <customErrors mode="On" /> in the web.config. I've setup 404 error pages on many installs where this has been set to "Off", which is also what I will recommend that you do. It should be enabled in order to show .net errors (yellow screen of death) in more detail.
2: Try writing this, where you only enter the id of your errorpage. <errors> <error404>56428</error404> </errors>
3: I'm not sure what the error message in the macro is all about - could you try removing it and see if you get redirected to the error page when you try to go to a page that does not exist?
If that works, try adding the macro back and add the ?umbdebugshowtrace=1 to the url and see if you get some usefull debugging information in the trace log.
One requirement which I need to emphasise is that, my custom error page needs to be displayed whenver any excpetion is raised, not only 404 errors. So preferably I need to configure Umbraco to use my page regardless of the error code - a generic catch all, just as you would with a usual ASP.NET site via the <customErrors> in web.config.
This is what I've been tinerking with (i.e. my attempts at editing the web.config and umbracoSettings.config), but not getting very far :(
I'm not sure if I may have missed something on that page, but they do look a bit specific. Did you say there was a component that could help with handling other error types?
I tend to just handle 404 errors so I'm not really sure.
Think you'll have roll your own provider for catching other types if you have other needs. But I think the uComponents handlers will be a pretty good starting point.
Basically I need to capture all errors, from 404 to exceptions thrown from code. Currently, when an exception is thrown, we end up with 2 scenarios:
If the exception happens at the Umbraco backend, then we get a Yellow Screen of Death.
If the exception happens at the front end site level, then Umbraco will just show a small message like "There was an error in something.cshtml" for example, on the page somewhere.
I'm looking to catch all errors so that I can show a custom error page to the user, both from the Umbraco backend and the front end site. This implies I may need to work out whether the error happened at the backend or the front end, since the styling of the error page needs to match the backend/front end.
Generally I'd expect exceptions in the back end to be handled more gracefully, usually with a popup dialog box in the bottom right - which version of Umbraco are you using?
The uComponents module should manage 404 and 301 errors?
If you're having exceptions in code, then no offence but you really shouldn't ?
You can supress errors with a try-catch by putting catch{} an this wil just skip over errors but I'd think spending the time to get rid of code errors would be a better move.
I think handling 404 errors and the like is fair enough because you want a good user experience if the site admin moves, renames or deletes a page, but anything code related really should be fixed before going live I think.
If you have any specific examples let me know and I'll try to help.
From what I understand the error that bothers you (error loading MacroEngine script) is caused by a bogus macro Razor script. Trouble is, as far as I know Umbraco currently catches these error and reports the message that you see ("error loading...") because some people don't want to kill the entire page because of an exception in one macro (the rest of the page could be correct). So the exception is captured by Umbraco, not thrown, and no global error page is displayed.
Does that match your situation?
Then I need to dig into the issue tracker, I think there was a feature request to have an option to have all errors that happen in macros be thrown and not captured as it is today... then a global error page would handle them.
Basically what you describe is similar to our situation.
We would like to use a custom error page since our customers, when an error does crop up, are not very good at describing what happened. Although we don't have many errors appear, when they do, it can be tricky for the customer to descirbe what happened, especially is Umbraco is masking errors by displaying it's own "Oops, something went wrong" kind of thing.
If we could capture more information about the error (i.e. by having a custom error page capture all errors) then we can more easily work out what's going on. We could also audit the errors in a custom table, rather then having to depend on the Umbraco error log table. We would like our own error logging in place too.
The other requirement is that we would like a custom error page to work for the front end site, and the backend Umbraco site. So I'm unsure what would be the best strategy for that.
So in the front-end an error in one macro in the page would kill the entire page (redirect to a global custom error page) but on the back-end it would give you a detailed report of what went wrong for each macro (I guess this is from within the RichText editor) ?
I've found a solution that works for me. Basically I use a Http module to capture the page-level errors, using a technique described in the blog article:
How to configure a custom error page.
I've scanned various articles, and forum posts here, which show how to configure custom error pages in Umbraco. However, atfer following these, I'm still not able to get my custom error page displayed to the user when an errror occurs.
Here is how I created and configured my custom error page:
Created new document type and template named "Error".
Created new content item named "Error" which uses the "Error" template.
Edit the web.config file - <customErrors mode="On" /> instead of "RemoteOnly"
Edit the umbracoSettings.config file like so:
<errors>
<errorPage culture="default">56428</errorPage>
<error404>1</error404>
</errors>
To test the error page, I have manually placed a "throw new Exception()" call in a .cshtml file which the site uses. When I navigate to the page which uses this cshtml file, the error displayed to the user is:
Error loading MacroEngine script (file: ConditionsGrid.cshtml)
I was expecting to see my Error.aspx page appear. I can navigate to error.aspx without any problems, but Umbraco isn't using that file when an error is raised.
Can someone suggest what I may have done wrong during the config please?
Hi Jason
Do you have a document type, which is using the error template? Or is the provided ID the id of the error template?
/Jan
Hi there.
Yes there is an "Error" document type, which is linked to an "Error" template.
I then created a new content item named "Error" in the root of my site. The ID of this item is 56428.
Cheers.
Hi Jason
Ok then...
1: It should not be neccesary to set the <customErrors mode="On" /> in the web.config. I've setup 404 error pages on many installs where this has been set to "Off", which is also what I will recommend that you do. It should be enabled in order to show .net errors (yellow screen of death) in more detail.
2: Try writing this, where you only enter the id of your errorpage.
<errors>
<error404>56428</error404>
</errors>
You can read more about the error page configuration in the documentation of umbracoSettings.config file here: http://our.umbraco.org/documentation/Using-Umbraco/Config-files/umbracoSettings/
3: I'm not sure what the error message in the macro is all about - could you try removing it and see if you get redirected to the error page when you try to go to a page that does not exist?
If that works, try adding the macro back and add the ?umbdebugshowtrace=1 to the url and see if you get some usefull debugging information in the trace log.
Hope some of these pointers help.
/Jan
You could take a look at this post - I use this for pretty much all my sites:
http://our.umbraco.org/wiki/how-tos/how-to-implement-your-own-404-handler
Hi guys.
Many thanks for your suggestions.
One requirement which I need to emphasise is that, my custom error page needs to be displayed whenver any excpetion is raised, not only 404 errors. So preferably I need to configure Umbraco to use my page regardless of the error code - a generic catch all, just as you would with a usual ASP.NET site via the <customErrors> in web.config.
This is what I've been tinerking with (i.e. my attempts at editing the web.config and umbracoSettings.config), but not getting very far :(
Cheers.
Take a look at the uComponents documentation
http://ucomponents.codeplex.com/documentation
I haven't used it but there does seem to be elements for handling different types of errors
Hi Richard.
Thanks for the link.
Here are the error handlers I could find:
I'm not sure if I may have missed something on that page, but they do look a bit specific. Did you say there was a component that could help with handling other error types?
Hi Jason
What other error types do you need to cover?
I tend to just handle 404 errors so I'm not really sure.
Think you'll have roll your own provider for catching other types if you have other needs. But I think the uComponents handlers will be a pretty good starting point.
Hi Richard.
Basically I need to capture all errors, from 404 to exceptions thrown from code. Currently, when an exception is thrown, we end up with 2 scenarios:
I'm looking to catch all errors so that I can show a custom error page to the user, both from the Umbraco backend and the front end site. This implies I may need to work out whether the error happened at the backend or the front end, since the styling of the error page needs to match the backend/front end.
Generally I'd expect exceptions in the back end to be handled more gracefully, usually with a popup dialog box in the bottom right - which version of Umbraco are you using?
The uComponents module should manage 404 and 301 errors?
If you're having exceptions in code, then no offence but you really shouldn't ?
You can supress errors with a try-catch by putting catch{} an this wil just skip over errors but I'd think spending the time to get rid of code errors would be a better move.
I think handling 404 errors and the like is fair enough because you want a good user experience if the site admin moves, renames or deletes a page, but anything code related really should be fixed before going live I think.
If you have any specific examples let me know and I'll try to help.
From what I understand the error that bothers you (error loading MacroEngine script) is caused by a bogus macro Razor script. Trouble is, as far as I know Umbraco currently catches these error and reports the message that you see ("error loading...") because some people don't want to kill the entire page because of an exception in one macro (the rest of the page could be correct). So the exception is captured by Umbraco, not thrown, and no global error page is displayed.
Does that match your situation?
Then I need to dig into the issue tracker, I think there was a feature request to have an option to have all errors that happen in macros be thrown and not captured as it is today... then a global error page would handle them.
Hi Stephen.
Basically what you describe is similar to our situation.
We would like to use a custom error page since our customers, when an error does crop up, are not very good at describing what happened. Although we don't have many errors appear, when they do, it can be tricky for the customer to descirbe what happened, especially is Umbraco is masking errors by displaying it's own "Oops, something went wrong" kind of thing.
If we could capture more information about the error (i.e. by having a custom error page capture all errors) then we can more easily work out what's going on. We could also audit the errors in a custom table, rather then having to depend on the Umbraco error log table. We would like our own error logging in place too.
The other requirement is that we would like a custom error page to work for the front end site, and the backend Umbraco site. So I'm unsure what would be the best strategy for that.
So in the front-end an error in one macro in the page would kill the entire page (redirect to a global custom error page) but on the back-end it would give you a detailed report of what went wrong for each macro (I guess this is from within the RichText editor) ?
I've found a solution that works for me. Basically I use a Http module to capture the page-level errors, using a technique described in the blog article:
http://blogs.microsoft.co.il/blogs/oshvartz/archive/2008/05/17/asp-net-error-handling-using-httpmodule-full-and-partial-post-back-ajax-updatepanel.aspx
I spotted a question on StackOverflow which seemed similar to my situation, so I posted my code there:
http://stackoverflow.com/questions/12950011/exception-logging-httpmodule-doesnt-catch-errors-from-asp-net-page-method/13348207#13348207
I'm hoping this will suffice for what we need for our site.
Cheers to all of you for your suggestions.
is working on a reply...