Page Not Found Handler

If you have questions about using mojoPortal, you can post them here.

You may want to first review our site administration documentation to see if your question is answered there.

This thread is closed to new posts. You must sign in to post in the forums.
11/3/2009 11:24:32 AM
Gravatar
Total Posts 2253

Page Not Found Handler

How do I make the 404 handler work when using IIS7 and Integrated Pipeline App Pools? The PageNotFoundHandler seems to work fine as long as I use Classic App Pools.

 

11/3/2009 11:34:28 AM
Gravatar
Total Posts 18439

Re: Page Not Found Handler

It works for me on my development machine I'm always using Integrated mode. As long as you have this in the <modules> section of Web.config it should work:

<add name="PageNotFoundHandler" type="mojoPortal.Web.PageNotFoundHttpModule, mojoPortal.Web" />

you might try changing it like this:

<add name="PageNotFoundHandler" type="mojoPortal.Web.PageNotFoundHttpModule, mojoPortal.Web" preCondition="managedHandler" />

and see if it makes a difference or also it could be an issue using extensionless urls vs using .aspx as I'm not using extensionless urls on my machine.

Hope it helps,

Joe

11/3/2009 11:51:37 AM
Gravatar
Total Posts 2253

Re: Page Not Found Handler

Hmm... I added the preCondition but it had no effect. I do get the following error in the app log:

2009-11-03 11:59:00,760 ERROR mojoPortal.Web.PageNotFoundHttpModule - 64.57.210.112  PageNotFoundHttpModule handled error.
System.Web.HttpException: The file '/thispageainthere.aspx' does not exist.
   at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
   at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
   at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
   at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
   at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

Thoughts?

-Joe

11/3/2009 11:56:16 AM
Gravatar
Total Posts 18439

Re: Page Not Found Handler

According to that message the PageNotFoundHandler handled it which means it should have shown the custom 404. What are you seeing in the browser? Maybe it can't find the custom404 page. Are you using the one included with mojoPortal or a different one?

11/3/2009 12:17:46 PM
Gravatar
Total Posts 2253

Re: Page Not Found Handler

I am seeing the standard IIS7 404 page (http://acckc.org/thispageainthere.aspx).

AFAIK I am using the custom404 page included with mojoPortal. I haven't adjusted anything to make it use something else.

-Joe

11/3/2009 1:25:04 PM
Gravatar
Total Posts 18439

Re: Page Not Found Handler

Are you running any additional IIS modules like url re-writers or anything that might be affecting it? Like , if you look at the modules list in IIS if there is a module listed higher in the list than the PageNotFoundHandler that may be doing something ith 404s before PageNotFoundHandler can respond.

Try also:

<add name="PageNotFoundHandler" type="mojoPortal.Web.PageNotFoundHttpModule, mojoPortal.Web" preCondition="" />

Also if you have this:

<modules runAllManagedModulesForAllRequests="true">

try changing to this:

<modules>

which will mean extensionless urls won't work but worth ruling out as a factor.

Hope it helps,

Joe

11/3/2009 1:45:32 PM
Gravatar
Total Posts 18439

Re: Page Not Found Handler

Just in case, the setting that would be used to use a custom page for the 404 is:

<add key="Custom404Page" value="/PageNotFound.aspx" />

so if you were overriding that in user.config it could be a factor.

11/3/2009 2:16:58 PM
Gravatar
Total Posts 2253

Re: Page Not Found Handler

I think I am going to try setting up a new site on a clean install of 2008 with IIS 7. I am having this issue on two different servers with any site using Integrated Pipeline. I was using the URL Rewrite tool from MS but I disabled it on one site and I still have the same issue. I have also tried moving the PageNotFoundHandler module to different locations in the <modules> section but to no avail.

I have been testing this on different sites on different servers. I am not sure if my control panel (DotNetPanel) has set something up in IIS that is messing with this or not. That is why I want to try using a clean install.

Thanks for your help. I will let you know what happens with the different server.

Thanks,
Joe D.

1/20/2010 5:21:46 PM
Gravatar
Total Posts 2253

Re: Page Not Found Handler

Hi Joe,

I have tried to resolve this issue in the past but I never found a solution and figured I was just doing something wrong. Honestly, I kind of forgot about it until today when I accidentally mis-typed a page on mojoportal.com. I noticed that the Page Not Found Handler isn't working properly on this site so I figured I would revisit this issue.

I have a mojo site setup on a clean 2008 server and the Page Not Found Handler doesn't work properly if I use a Integrated Pipeline application pool.

Any thoughts?
Joe D.

1/20/2010 5:47:11 PM
Gravatar
Total Posts 2253

Re: Page Not Found Handler

Hey Joe,

I have two different results in the log for the PageNotFoundHandler depending on whether I use Integrated vs Classic app pools.

When using Integrated App Pool I get:

2010-01-20 17:32:49,257 ERROR mojoPortal.Web.PageNotFoundHttpModule - 10.117.198.60 PageNotFoundHttpModule handled error.
System.Web.HttpException: The file '/whois.aspx' does not exist.
at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)

at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
  at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

 

 

When using Classic App Pools I get:

2010-01-20 17:34:27,725 ERROR mojoPortal.Web.PageNotFoundHttpModule - 10.117.198.60 PageNotFoundHttpModule handled error.
System.Web.HttpException: The file '/whois.aspx' does not exist.
at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig)
at System.Web.HttpApplication.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
  at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

 

You'll notice that everything is the same until the bolded line above. Does that shed any light on the issue?

Thanks,
Joe D.

1/21/2010 5:46:45 PM
Gravatar
Total Posts 1203
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Page Not Found Handler

Hey guys, pardon me for butting in here. I'm pretty new to Mojo, and I was just exploring the friendly 404 feature to see how it works and how I can customize it. What I'm finding is that the handler's not working on my dev site. It also doesn't seem to be working on www.mojoportal.com and demo.mojoportal.com. On all three, when I hit an invalid URL I get the generic "Server Error, 404 - File or directory not found. The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable." On my site, the System Log shows this error (seems identical to Joe D's):
 

2010-01-21 15:37:38,942 ERROR mojoPortal.Web.PageNotFoundHttpModule - 10.1.102.199 PageNotFoundHttpModule handled error.
System.Web.HttpException: The file '/bzzzzzt.aspx' does not exist.
at System.Web.UI.Util.CheckVirtualFileExists(VirtualPath virtualPath)
at System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile)
at System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert)
at System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath)
at System.Web.UI.PageHandlerFactory.GetHandler(HttpContext context, String requestType, String virtualPath, String path)
at System.Web.HttpApplication.MaterializeHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
 

I'm running IIS 7 under Windows Server 2008 standard.


Thanks,

Jamie

1/22/2010 8:37:30 AM
Gravatar
Total Posts 18439

Re: Page Not Found Handler

Hi All,

I was able to figure out the cause and find a solution for the PageNotFoundHandler not working on IIS 7. The problem also surfaced on this recent thread. Basically it turns out that this is an IIS 7 specific issue, it worked fine all along on IIS 6 and it works fine on my Win 7 development machine which has IIS 7.5. So until recently when I moved mojoportal.com and demo sites from IIS 6/Win 2003 to IIS7/Win 2008 I was not seeing this issue myself. I really had not noticed the 404 handler not working on this site and demo.mojoportal.com after the initial move until someone pointed it out.

So after some research I found there is a way to change this behavior on IIS 7 using some command line commands, however, I'm not command line guru and was hoping for some easy to change setting from the UI so I kept looking a bit and found this solution in Rick Strahl's blog which involves 1 line of code added to our PageNotFoundHttpModule:

app.Context.Response.TrySkipIisCustomErrors = true;

I did not have a test environment with IIS 7 all setup so I deployed a new build on demo.mojoportal.com to verify this solved the issue and then also redployed a new build here on mojoportal.com to solve it here.

This fix will be in svn trunk by later tonight and will be in the next release.

Best,

Joe

1/22/2010 8:58:20 AM
Gravatar
Total Posts 2253

Re: Page Not Found Handler

Hi Joe,

 

Awesome! I am looking forward to the next release.

I am going to give the command line options a try just for kicks. I am an old command line guy so it will be fun! (yeah that's way nerdy)

Thanks!
Joe D.

1/22/2010 10:10:36 AM
Gravatar
Total Posts 2253

Re: Page Not Found Handler

Hello All,

Okay, so I used this command to allow the PassThrough of the response from the PageNotFoundHandler:

C:\Windows\System32\inetsrv>appcmd.exe set config "websiteName/" -section:system.webServer/httpErrors -existingResponse:PassThrough

 

And it added this to my web.config after the handlers section in the system.webServer section:

<httpErrors existingResponse="PassThrough" />

So, I copied that line to another web.config on a different site and all is well with the PageNotFoundHandler.

HTH,
Joe D.

1/26/2010 6:48:22 PM
Gravatar
Total Posts 1203
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Page Not Found Handler

Thanks, guys! Joe D., that web.config modification was perfect for me, since I have a user demo coming up tomorrow morning and don't want to risk rebuilding from SVN source so soon before that demo.

 

3/9/2010 10:46:12 AM
Gravatar
Total Posts 1203
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Page Not Found Handler

Okay, I have a new question about this, and I'm not sure if this is a bug or a feature request.

If you navigate to http://demo.mojoportal.com/bogus/default.aspx, you get the friendly 404 page.

However, if you navigate to http://demo.mojoportal.com/bogus, http://demo.mojoportal.com/bogus/, or http://demo.mojoportal.com/bogus/index.html, you receive the generic IIS 404 page.

Is it possible to make the URLs in the second scenario also bring up the friendly 404 page? This is very important to us since our current site is HTML based, and without this capability, when we cut the site over to mojoPortal, all existing bookmarks and previously published URLs will lead to a generic 404 page. Obviously, we'd much prefer to have the friendly 404 page come up instead.

Thanks as always, Joe!

Jamie

3/9/2010 10:54:55 AM
Gravatar
Total Posts 2253

Re: Page Not Found Handler

Hi Jamie,

The reason you are not getting the friendly 404 page when using /bogus or *.html is ASP.NET is not setup to handle all requests to the site, only .NET requests.

You can change this behavior by adding runAllManagedModulesForAllRequests="true" to the Modules section of your web.config. So it will look like this:

<modules runAllManagedModulesForAllRequests="true">

You can find the modules section on or about line 1116 in your web.config.

Please note that this will cause all traffic to go through .NET which may be quite a performance hit for your site.

Also keep in mind that this change is in the web.config and not the user.config so you will have to add this setting to your web.config after each upgrade.

HTH,
Joe D.

3/9/2010 10:56:36 AM
Gravatar
Total Posts 2253

Re: Page Not Found Handler

Hi Jamie,

Scratch that. I shoud've tested before posting, not afterwards. I have this setting on my website but the friendly 404 isn't showing up when I use something like /bogus. I thought it would.

I will keep trying. Maybe I'll figure it out.

Thanks,
Joe D.

3/9/2010 11:07:04 AM
Gravatar
Total Posts 18439

Re: Page Not Found Handler

It is also possible to create a custom 404 page in IIS, the process varies depending on IIS version but a little googling should get you going, this thread may help.

Hope it helps,

Joe

3/9/2010 4:27:51 PM
Gravatar
Total Posts 1203
Proud member of the mojoPortal team

Help support mojoPortal!
Add-on modules

Re: Page Not Found Handler

Hey guys, thanks for the tips. I believe I have this figured out now, thanks to this page. For step 6, I used the option "Execute a URL on this site" and pointed it to /PageNotFound.aspx so mojoPortal would handle the error, and I wouldn't need to worry about custom styling a static page. Now, all 404 requests seem to be going to mojoPortal's friendly page. Yay! cool The change also correctly affects sub-sites.

As a result of this change, the following section was added to Web.config below the <handlers> section "Handlers for IIS 7.0 Integrated mode":

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

Joe, can you include this section in the default Web.config you are distributing with mojoPortal? I think this would be a very worthwhile change, as long as it doesn't interfere with people using versions of IIS other than 7.

Jamie

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