Web.Config customErrors not redirecting

This is an open forum for any mojoPortal topics that don't fall into the other categories.

This thread is closed to new posts. You must sign in to post in the forums.
5/5/2009 5:29:56 PM
Gravatar
Total Posts 42

Web.Config customErrors not redirecting

I am having trouble configuring my web.config to handle errors. I created a custom error page, the cms is not redirecting to the page on any errors. Here's the snippet of my web.config

<customErrors mode="RemoteOnly" defaultRedirect="~/myerror.aspx" />

 

 

5/6/2009 6:25:32 AM
Gravatar
Total Posts 18439

Re: Web.Config customErrors not redirecting

Hi Steve,

The problem with using a .aspx page for the custom error page is that if the error is deep in the runtime and asp.net is not working then the error page will throw errors as well, that is why I use a plain html page for the custom error page.

Note that mode="RemoteOnly" means it will only redirect remote clients, it will not redirect if you are sitting at the machine and using localhost. If you want to test that on localhost you have to set mode="On"

Hope it helps,

Joe

5/6/2009 8:33:05 AM
Gravatar
Total Posts 42

Re: Web.Config customErrors not redirecting

Even with a .htm and mode set to On the redirect fails.

5/6/2009 9:43:22 AM
Gravatar
Total Posts 18439

Re: Web.Config customErrors not redirecting

Only other things I can think of is if there are overriding settings in machine.config or if the site is running in a sub directory like hostname/mojo then maybe if there is a Web.config in the root of the site it is overriding the one in the sub folder, or some other server configuration issue. I cannot produce the problem.

Best,

Joe 

5/7/2009 2:34:00 PM
Gravatar
Total Posts 42

Re: Web.Config customErrors not redirecting

The issue had to due with a machine.config. I was able to get around it with:

<system.webServer>

  <httpErrors errorMode="Custom">

     <clear/>

     <error statusCode="404" path="/myerrorpage.html" responseMode="ExecuteURL"/>

  </httpErrors>

</system.webServer>

 

5/8/2009 6:43:48 AM
Gravatar
Total Posts 18439

Re: Web.Config customErrors not redirecting

Ahh, I see the light now. The problem is because we should have that in the system.webserver section in the mojoportal Web.config. I did not know there was a setting that could be placed there but it makes total sense. As you have probably noticed there are a number of things in the system.webserver section that seem to be duplicates for things in the system.web section, like httpmodules and handlers, and apparently the custom error handling should also go there.

Basically its like this, IIS 6 will use the settings from system.web, and IIS 7 if configured with a "Classic" app pool will also use the settigns from system.web, but IIS 7 using the new default "Integrated Pipelione Mode" uses the settings from the system.webserver section and not the corresponding ones from system.web.

Even though I develop every day using IIS7 in Integrated pipeline mode I had not noticed any problem about the error redirect because I don't expect it to redirect when I'm working locally at localhost. But my production environment is IIS6 so my production sites were redirecting just fine and I never noticed that there should be this error section in system.webserver section.

I will add it now so it will be there for the next release.

Thanks,

Joe

5/8/2009 9:40:14 AM
Gravatar
Total Posts 18439

Re: Web.Config customErrors not redirecting

Hmm, It seems I can't really add this to the mojoportal Web.config except in comments. By default this httpErrors section is locked down at a parent configuration file, probably machine.config. So the only way it can be used in the Web.config is if it is unlocked.

There also exist the possibility of the error module not being installed in IIS 7 as it is an optional item when you install IIS 7 under windows feature installation.

So I will add it in coments with notes and a link to msdn documentation.

Best,

Joe

You must sign in to post in the forums. This thread is closed to new posts.