Try our conversational search powered by Generative AI!

Custom Error Page

Hi! I have some problems setting up a custom error page correctly. I have turned off EPi's error handling. So everything works as I want for .aspx files. However the don't for other file types. When I change the 404-page in IIS according to this article some CSS-files aren't found and things look pretty fubar, mostly in edit and admin mode. I think it has something to do with what is discussed in this article: How can I set the 404-error page to my custom page without encountering the css-problem????
Jan 11, 2006 11:14
You need to have an error page that is an aspx file. Many functions in EPiServer uses the ability to catch PageNotFoundException example the Page___XXXX.aspx functionality. For that to happen the errorpage nedds to be an aspx file so that the .net framework kicks starts even for requests with no valid page. /HAXEN
Jan 11, 2006 14:37
I had the 404 pointing to one of my EPI-pages, which is an aspx. This didn't work. However pointing it to a regular aspx-page, that did nothing but call Response.Redirect to the epi-page I really wanted to load, did work. Don't ask me why.
Jan 11, 2006 16:01
Just make sure your 404 design and implementation is clean and functional. You do not want to end up in a endless 404 loop. Additionally, EPiServer will throw an PageNotFoundException if you specify an invalid id, which will not be redirected to your 404 handler. /Steve
Jan 11, 2006 21:51
Steve - any idea why it doesnt redirect to the 404 handler? How should you handle an invalid id? Do you have to catch the PageNotFoundException in the Application_Error function for example? /John
Jan 17, 2006 17:51
I haven't looked to much into it, but I can think of two things: 1. The SpiderSupport httpmodule has been removed from the httpModules section in web.config. 2. There might be some code in the spider module that short circuit the error handler (I believe robot friendly url's will give you trouble here.) Yes, to catch the PageNotFoundException, add your own handler to the Error event during application start-up (in global.asax), and check for that exception there. You could also check for other errors there, like System.IO.FileNotFoundException which will be thrown for missing files that are configured for Also, handle the HttpException, but only for the 404 code, and you'll cover most of the 404's.
Jan 17, 2006 23:59
I'm still having problems with this. my web config looks like this: In my Application_Start I have Global.EPDataFactory.LoadingPage += new PageEventHandler(ErrorHandler); in the ErrorHandler function I just have a try/catch which catches any exception and performs a redirect to another page just for testing. It works if I run from the server but not on remote machines despite having the option customErrors mode="On" Anybody got any ideas why? Is this a bug? Anyone browsing to a page with an invalid id from any machine than the server gets episervers standard error page but when i run locally on the server I get my error page. /John
Jan 18, 2006 14:53
When I say it works I mean the stuff in the web config works but the error handler never gets used. /John
Jan 18, 2006 15:22
My research shows that it makes no difference what is in the custom errors section in IIS as long as I have It also makes no difference if its On or RemoteOnly - except when its set to off and Im browsing on localhost I get "Server Error in '/' Application" - EPiServer.Core.PageNotFoundException: Page 529122 was not found. Just like when I browse from any other machine that is not localhost. I can point the 404 custom error page in IIS to anything - even a page that doesnt exist asp or aspx. It makes no difference if I am trying to surf a page with an invalid ID from another machine if im logged in or not logged in. I just get to see the stack trace when I am logged in and not when im not. I wonder therefore if this is a bug because my error handling code only gets run if im running on localhost (the desired result) and if Im browsing on any other machine I get "Server Error in '/' Application" - EPiServer.Core.PageNotFoundException: Page 529122 when i should get directed to my error page. Has anyone else had this problem? Is it a version problem? I am running 4.30 at the moment with an upgrade due before Åre :)
Jan 19, 2006 13:46
dump from running from a remote machine: Page 529122 was not found at EPiServer.DataAccess.PageLoadDB.Load(PageReference pageLink) at EPiServer.DataFactory.?(PageReference ) at EPiServer.DataFactory.GetPage(PageReference pageLink, AccessLevel access) at EPiServer.PageBase.GetPage(PageReference pageLink) at EPiServer.SimplePage.get_CurrentPage() at EPiServer.EditPage.get_CurrentPage() at EPiServer.Core.LanguageManager.GetContextLanguage() at EPiServer.PageBase.get_EPLanguage() at EPiServer.PageBase.get_EPLocale() at EPiServer.PageBase.ActivateLocale() at EPiServer.PageBase.?() at EPiServer.PageBase.OnInit(EventArgs e) at EPiServer.TemplatePage.OnInit(EventArgs e) at development.Templates.Page.OnInit(EventArgs e) in C:\Inetpub\lvninternwebutv\root\templates\Page.aspx.cs:line 45 at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Page.ProcessRequestMain() Other notes: The error code that I use sits in the Application_Error()function in global.ascx I have 2 event handlers in Application_Start(): Global.EPDataFactory.FailedLoadingPage += new PageEventHandler(ErrorHandler); Global.EPDataFactory.LoadingPage += new PageEventHandler(ErrorHandler); None of those ever get triggered during my tests. /John
Jan 19, 2006 14:10
It's a litte more complex than that. I don't have all of this in my head right now, but don't bother with the ASP.NET custom errors stuff. Turn off the EPiServer error handler, it will get in your way. Hook the Error event, not the FailedLoadingPage, this is where you can handle the exceptions. I'll show you a working version of this in Åre if you'd like to see it :-) /Steve
Jan 19, 2006 15:33
Great Steve - see u on the train maybe - I'll be on from Gävle! I have hooked the Error event, as u said the EPiServer error handler is getting in my way it seems... How do you turn off the EPiServer error handler? /John
Jan 20, 2006 10:15
Hi, I won't be on the train, leaving directly from Oslo. Turn off the error handler by setting EPsErrorHandling to Off. /Steve
Jan 21, 2006 12:41
Thanks Steve - that fixed it! /John
Jan 23, 2006 9:52


When i tried to access the forum page in relateplus i am getting the following error in pagebase class.

if (_generalErrorPage == null)
_generalErrorPage = DataFactory.Instance.GetPage((PageReference)_startPage["GeneralErrorPage"]);


Can anyone pls figure out this issue?

Thanks in advance.


Feb 24, 2012 5:48
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.