404 page doesn't display when requesting invalid folder names or files not having an .aspx extension

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.
3/5/2012 8:10:38 PM
Gravatar
Total Posts 19

404 page doesn't display when requesting invalid folder names or files not having an .aspx extension

Hi there,

I noticed on our site that when visiting an invalid url having an '.aspx' extension in it, for example 'http://mysite/1234.aspx', MojoPortal's 404 redirect displays correctly. No problem. However, if we try to access a folder name or file that doesn't have an aspx extension, for example 'http://mysite/1234.html' or 'http://mysite/1234' or some other URL that doesn't exist, then we get an ugly 'Server error' 404 error message (not MojoPortal's nice custom looking one).  It seems like MojoPortal is not handling the error because the request is lacking an .aspx extension?  If this is expected behavior what would you recommend for us as a solution?

Thank You!

3/6/2012 9:49:34 AM
Gravatar
Total Posts 18439

Re: 404 page doesn't display when requesting invalid folder names or files not having an .aspx extension

Hi,

The problem happens when IIS returns a 404 before the request can even reach mojoPortal code and mojoPortal can do nothing in that case.

I've had some mixed success with handling 404 for pages with no extension like http://yoursite/foo

It works for me on my local machine with IIS 7.5 by adding this in user.config:

<add key="DetectPageNotFoundForExtensionlessUrls" value="true"/>

and by changing this in Web.config

from this:

<modules>

to this:

<modules runAllManagedModulesForAllRequests="true">

but I find it does not work on my server which is Win 2008 with IIS 7.0

it also doesn't seem to work for extensions that already may have handler mappings like foo.html

The best solution I can suggest is to make a custom static html file with a similar design as your site and configure it as the 404 page for your site in IIS or do some googling about "iis 7 custom 404" for more ideas.

Hope that helps,

Joe

3/6/2012 11:23:58 AM
Gravatar
Total Posts 1203
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: 404 page doesn't display when requesting invalid folder names or files not having an .aspx extension

Here's what we're using in our web.config in IIS 7:

<httpErrors>
   <remove statusCode="404" subStatusCode="-1"/>
   <error statusCode="404" prefixLanguageFilePath="" path="/PageNotFoundCustom.aspx" responseMode="ExecuteURL"/>
</httpErrors>

Joe's comment in web.config indicates that this setting is commented out because it's locked down somewhere else in IIS 7, but in our experience it works perfectly and redirects all 404s to the custom page.

Jamie

 

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