Page 1 of 1

Odd behavior with 404 custom errors page

Posted: Tue Sep 06, 2016 3:45 am
by AbleMods
After moving my entire hosting business to new platforms, an unusual behavior has appeared when it comes to 404 custom errors.

The problem we're having is the default IIS error page renders even though customErrors = "on" and the 404 error is specified (default able web.config).

I traced it down to the /Errors/PageNotFound.aspx.cs file. The page is forcing the Response.Status to '404 Not Found'. Which, on my old hosting platform, worked just dandy.

But the new platform doesn't like it. When Response.Status is forced to 404, the default IIS 404 page renders and not the custom error page found in the site.

I did some googling and found that an additional web.config setting is necessary. This goes in the <system.webServer> section:
<httpErrors existingResponse="PassThrough" />
When that setting is present in the web.config, the site correctly renders the custom error page specified in the web.config.

As for why this is necessary, that part I don't understand. The hosting move involved going from Server 2008 to Server 2012, so that could be part of it. Or there could be some sort of default application.config setting on the new platform that didn't exist on the old hosting platform. Very puzzling, but at least I found a solution. I'm posting it here in case anyone else runs into the same problem where IIS renders a default error page even though custom error pages are specified in the web.config.

Re: Odd behavior with 404 custom errors page

Posted: Tue Sep 06, 2016 5:47 am
by Katie
Do you happen to use extension-less URLs?

There is a known issue with the custom error pages that we just documented. Please see:

http://wiki.ablecommerce.com/index.php/ ... rror_pages

Re: Odd behavior with 404 custom errors page

Posted: Tue Sep 06, 2016 8:35 am
by AbleMods
No I do not think so. Isn't that a store setting you can turn on or off?

Re: Odd behavior with 404 custom errors page

Posted: Wed Sep 07, 2016 12:33 am
by mazhar
Joe what you noticed happened earlier with websites having extension less URLs. It was discussed here
viewtopic.php?f=65&t=18776

Apparently asp.net overlooked customErrors settings in web.config when missing URL was an extension less URL. It was always jumping towards IIS default 404 page. If missing URL is not extension less in your case then I am not sure why its happening, can you post the complete missing URL here ? Does it have .aspx in it?

Re: Odd behavior with 404 custom errors page

Posted: Wed Sep 07, 2016 12:38 am
by AbleMods
In this case, it was any invalid aspx page name. I was just trying to get the PageNotFound page to even load. So even something like clientsite.com/blahblah.aspx would render the default IIS page instead of ~/Errors/PageNotFound.aspx.

This client isn't even using extensionless urls so far as I know.