Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I am trying to create a .NET UserControl for my Custom Error Page that gets the HTTP Error Code from the Server and then uses that to determine with message to display, but unfortunately it looks like Umbraco might be clearning the Error before it redirects to my Custom Error Page.
The goal here is to have one custom error page that is smart enough to get the error code from the server and display the appropriate message without the need to create a page for each specific error message.
To better clarify what I have going on, here's an overview.
I already updated umbracoSettings.config to redirect 404 to my custom page and this part is working.
In my usercontrol, I am trying to get the last error from the server by doing the following:
var Server = HttpContext.Current.Server;Exception httpException = Server.GetLastError();
httpException is always null, meaning that the last error on the Server is likely being cleared before the custom page is loading. This is where I am getting stuck. When I test httpException, it's always null and I display a generic error message, never giving me a chance to get the http code.
It's worth mentioning that I am getting to the custom Error Page and it is displaying properly, I just can't get the Error from the server that sent the user to this page, which in this case is a 404.
Is Umbraco clearing the error? If so, is there an easy way to get it to stop doing that without having to modify anything in Umbraco Core? Am I barking up the wrong tree needing to look for the http error code that sent us to this page elsewhere?
Thanks in advance!
Did you find more about this?
I am trying to get @Server.GetLastError() however it's null on any template page.
I never got anywhere with this and ended up abandoning it... Sorry!
There are a couple other ways which I am just looking at the moment:
or using a extension method for UmbracoApplication
protected new void Application_Error(object sender, EventArgs e)
var lastError = Server.GetLastError();
if (lastError != null)
I can keep this updated when done.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted