Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to intercept 404 file not found responses

18 views
Skip to first unread message

SvenC

unread,
Jul 6, 2009, 3:26:39 AM7/6/09
to
Hi,

I would like to redirect a client when SharePoint Services 3.0 or MOSS 2007
give back a 404 status code.

I tried to use ASP.Net and IIS custom error pages but they do not get used -
WSS always returns status 404 and a response text of 404 NOT FOUND.
I was already pointed to the WSS SDK and SPWebApplication.FileNotFoundPage
which indicates that SharePoint does not make it easy to handle 404.

I added a custom IHttpModule and handled events like PreSendRequestHeaders,
PostRequireRequestState, PostRequestHandlerExecute, PreSendRequestContent
and EndRequest, but the StatusCode in those call backs is always 200, even
if the client gets back 404.

I tried to position my custom handler at the beginning of the httpModules
section and at the end (only one at any time), just in case the execution
sequence of the HttpModules relative to SPRequest is of importance - made no
difference.

It seems that some WSS ISAPI filter or extension is getting in the way, so
that
IHttpModules cannot handle this?

What can I do to intercept (and redirect or change the content of) HTTP
error responses?

--
SvenC

Steven Cheng

unread,
Jul 7, 2009, 5:20:12 AM7/7/09
to
Hi SvenC,

As for the 404 error page for sharepoint application, it is different from
the normal IIS or ASP.NET application since sharepoint runtime generally
intercept all the page processing itself. Therefore, simply change custom
error page in IIS virutal Directory will not work.

Here is a knowlege base article which explained how to customize the error
page in sharepoint site(WSS and MOSS):

#How to point to a custom 404 error Web page in Windows SharePoint Services
3.0 or in Microsoft Office SharePoint Server 2007
http://support.microsoft.com/kb/941329

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.


--------------------
From: "SvenC" <Sv...@nospam.nospam>
Subject: How to intercept 404 file not found responses
Date: Mon, 6 Jul 2009 09:26:39 +0200

SvenC

unread,
Jul 8, 2009, 11:05:00 AM7/8/09
to

Hi Steven,

I answered with Windows Live Mail and a jpg screenshot but the post simply
does not show up - strange? So I repost just the text part through the web
news interface.

> As for the 404 error page for sharepoint application, it is different from
> the normal IIS or ASP.NET application since sharepoint runtime generally
> intercept all the page processing itself. Therefore, simply change custom
> error page in IIS virutal Directory will not work.
>
> Here is a knowlege base article which explained how to customize the error
> page in sharepoint site(WSS and MOSS):
>
> #How to point to a custom 404 error Web page in Windows SharePoint
> Services
> 3.0 or in Microsoft Office SharePoint Server 2007
> http://support.microsoft.com/kb/941329

I tried the steps shown for WSS (I use 3.0 SP2) but the output in case of
404 looks rather incomplete. I used the error.htm as a template file and
without any modification I get the attached picture with IE 8 (the picture
shows a white only background, no images, no SharePoint themeing,
only a "Go back to site" link, underneath the text Error in bold and a bit
down the text "Troubleshoot issues with Windows SharePoint Services."

Looks like the relative paths to sharepoint locations for css and images
and so on are not working for 404 processing?

What can I do redirect to another URL based on the URL which
did produce the 404 error? So I want to dynamically create the
redirection URL based on the failing URL.
I would like to build a solution which works for IIS 6, 7 and 7.5

Thanks for your help,
Sven

SvenC

unread,
Jul 11, 2009, 9:24:55 AM7/11/09
to
Hi Steve,

did you see my last answer/question?

Can you help me to find a solution for my below question?

"What can I do redirect to another URL based on the URL which
did produce the 404 error? So I want to dynamically create the
redirection URL based on the failing URL.
I would like to build a solution which works for IIS 6, 7 and 7.5"

Regards,
Sven

Steven Cheng

unread,
Jul 13, 2009, 4:16:36 AM7/13/09
to
Hi SvenC,

As for the custom 404 page, it is a static htm template file. I've tried
using an aspx page (with some server-side code inside), but it will not get
executed. Actually, the 404 error page for sharepoint has nothing to do
with IIS custom error page since sharepoint engine handle it completely.
Now, the only thing I can get is add some client side script in your
custom error page which redirect the user to another custom page(may an
aspx page in _layouts folder or some other pages you added on site).
However, it seems we cannot get the url of the failing page since custom
404 page is a htm template which does have server-side code execution
support.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.


--------------------
From: "SvenC" <Sv...@nospam.nospam>
References: <#Jh8asg$JHA....@TK2MSFTNGP03.phx.gbl>
<HecrnQu$JHA....@TK2MSFTNGHUB02.phx.gbl>
In-Reply-To: <HecrnQu$JHA....@TK2MSFTNGHUB02.phx.gbl>
Subject: Re: How to intercept 404 file not found responses
Date: Sat, 11 Jul 2009 15:24:55 +0200

SvenC

unread,
Jul 13, 2009, 4:37:30 AM7/13/09
to
Hi Steven,

> As for the custom 404 page, it is a static htm template file. I've tried
> using an aspx page (with some server-side code inside), but it will not
> get
> executed. Actually, the 404 error page for sharepoint has nothing to do
> with IIS custom error page since sharepoint engine handle it completely.
> Now, the only thing I can get is add some client side script in your
> custom error page which redirect the user to another custom page(may an
> aspx page in _layouts folder or some other pages you added on site).
> However, it seems we cannot get the url of the failing page since custom
> 404 page is a htm template which does have server-side code execution
> support.

Too bad... Any changes in SharePoint 2010? My company was accepted
in the upcoming beta program. I am not sure if or how much developer
documentation will be available. If you have information and could point
me in the right direction for SP 2010 (will it be WSS 4.0?) that would help
me getting started when we get our hands on SP 2010.

As for WSS 3.0 and MOSS 2007: how are the chances to develop an
ISAPI extension which coexists with the WSS extensions on IIS and
picks up 404 errors and redirects them?

Regards,
Sven

Steven Cheng

unread,
Jul 14, 2009, 4:52:52 AM7/14/09
to
Thanks for your reply Sven,

So far I haven't found any document on the custom ISAPI approach as the
built-in SPHandler seems not customizable. I'll do some further research to
see whether there is anything else we can try on this scenario. I'll keep
you informed if there is anything I find.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.

--------------------
From: "SvenC" <Sv...@nospam.nospam>


Subject: Re: How to intercept 404 file not found responses

Date: Mon, 13 Jul 2009 10:37:30 +0200

SvenC

unread,
Jul 14, 2009, 3:41:59 PM7/14/09
to
Hi Steve,

> So far I haven't found any document on the custom ISAPI approach as the
> built-in SPHandler seems not customizable. I'll do some further research
> to
> see whether there is anything else we can try on this scenario. I'll keep
> you informed if there is anything I find.

Thank you very much for your efforts.
I am looking forward to your findings.

Best regards,
Sven

Steven Cheng

unread,
Jul 15, 2009, 5:57:16 AM7/15/09
to
Hi Sven,

After some further researching, I've got some good news from some other
MOSS engineer. Here is a good reference on creating an enhanced 404 error
page:

#Creating a Enhanced MOSS 404 Feature - Part 1
http://www.sharepointbrainfreeze.com/archive/2008/09/29/creating-a-enhanced-
moss-404-feature-part-1.aspx

and this one has even been provided as a codeplex project:

http://www.codeplex.com/sharepointsmart404

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msd...@microsoft.com.

==================================================


Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.

--------------------
From: "SvenC" <Sv...@nospam.nospam>
In-Reply-To: <xLMmDCGB...@TK2MSFTNGHUB02.phx.gbl>


Subject: Re: How to intercept 404 file not found responses

Date: Tue, 14 Jul 2009 21:41:59 +0200

SvenC

unread,
Jul 15, 2009, 6:59:25 AM7/15/09
to
Hi Steven,

> After some further researching, I've got some good news from some other
> MOSS engineer. Here is a good reference on creating an enhanced 404 error
> page:
>
> #Creating a Enhanced MOSS 404 Feature - Part 1
> http://www.sharepointbrainfreeze.com/archive/2008/09/29/creating-a-enhanced-
> moss-404-feature-part-1.aspx
>
> and this one has even been provided as a codeplex project:
>
> http://www.codeplex.com/sharepointsmart404

Sound promising! I'll try it out in the next few days - a bit busy right
now.

Thanks a lot!
Sven

Steven Cheng

unread,
Jul 19, 2009, 9:55:34 PM7/19/09
to
Thanks for reply Sven,

Hope it helps you.

SvenC

unread,
Jul 28, 2009, 3:52:17 AM7/28/09
to
Hi Steven,

""Steven Cheng"" <stc...@online.microsoft.com> wrote in message news:vV6d10NC...@TK2MSFTNGHUB02.phx.gbl...


> Thanks for reply Sven,
>
> Hope it helps you.

Yes it does!

Thank you,
Sven

0 new messages