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

Custom not found and HTTP status code

2 views
Skip to first unread message

Nick Horrocks

unread,
Nov 8, 2004, 5:27:41 AM11/8/04
to
I have set up a custom error page for 404 errors.

However the HTTP status code returned is 302 followed by 200, this causes
search engines not to remove old pages from their index.

How can I get the correct status code to be returned?

Thanks


Jim Cheshire [MSFT]

unread,
Nov 8, 2004, 3:44:45 PM11/8/04
to
Hi Nick,

Don't use a custom error page. A custom error page will always cause the
Web server to redirect the user to the custom error page. That is done
using a Response status of 302 with a Location header.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
ASP.NET Developer Support
jame...@online.microsoft.com

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
| From: "Nick Horrocks" <nickho...@hotmail.com>
| Subject: Custom not found and HTTP status code
| Date: Mon, 8 Nov 2004 10:27:41 -0000
| Lines: 10
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441
| Message-ID: <OP$DI2XxE...@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 213.52.137.34
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!tornado.fastwebnet.it!tiscali!new
sfeed1.ip.tiscali.net!news.glorb.com!cyclone.bc.net!msrtrans!TK2MSFTNGP08.ph
x.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.aspnet:274313
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Nick Horrocks

unread,
Nov 9, 2004, 4:05:46 AM11/9/04
to

In that case how can I display a message to users telling tham that the page
has moved while at the same time responding with a 404 HTTP status. Just as
I can with IIS.


"Jim Cheshire [MSFT]" <jame...@online.microsoft.com> wrote in message
news:RX9pNPd...@cpmsftngxa10.phx.gbl...

Jim Cheshire [MSFT]

unread,
Nov 9, 2004, 3:36:56 PM11/9/04
to
Nick,

You can't if you are going to use a customErrors page. If you rely on
ASP.NET to do the redirect to the custom error page, you are going see a
302 for the redirect. If you don't want that, you have to control this at
the IIS level.

Jim Cheshire [MSFT]
MCP+I, MCSE, MCSD, MCDBA
ASP.NET Developer Support
jame...@online.microsoft.com

This post is provided "AS-IS" with no warranties and confers no rights.

--------------------
| From: "Nick Horrocks" <nickho...@hotmail.com>

| References: <OP$DI2XxE...@TK2MSFTNGP11.phx.gbl>
<RX9pNPd...@cpmsftngxa10.phx.gbl>
| Subject: Re: Custom not found and HTTP status code
| Date: Tue, 9 Nov 2004 09:05:46 -0000
| Lines: 58


| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441

| Message-ID: <efEzOtjx...@TK2MSFTNGP09.phx.gbl>


| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 213.52.137.34
| Path:

cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09
phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.aspnet:274629
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Nick Horrocks

unread,
Nov 10, 2004, 4:39:44 AM11/10/04
to
Well that seems a really appauling oversight.

I would be very happy for IIS to handle ALL 404 errors. However, if I want
to trap errors and display a nice message to the user I have to abandon
normal HTTP standards for 404 errors on any page with a .ASPX extension.


"Jim Cheshire [MSFT]" <jame...@online.microsoft.com> wrote in message

news:x2vchvpx...@cpmsftngxa10.phx.gbl...

Jim Cheshire [MSFT]

unread,
Nov 10, 2004, 10:30:27 AM11/10/04
to
Nick,

It's not an oversight. It's because of the way that ISAPI works with IIS.
In order for an IIS status code to be redirected to a custom page without a
302, it has to be handled by IIS itself. Once you pass that layer and get
into the ASP.NET ISAPI dll, you can no longer redirect without a 302.
There is no way around that.

In the case of a 404, you are only returning that if a page that is
requested does not exist. Therefore, I fail to see why you cannot simply
handle this with IIS.

Jim Cheshire [MSFT]


MCP+I, MCSE, MCSD, MCDBA
ASP.NET Developer Support
jame...@online.microsoft.com

This post is provided "AS-IS" with no warranties and confers no rights.


--------------------
| From: "Nick Horrocks" <nickho...@hotmail.com>
| References: <OP$DI2XxE...@TK2MSFTNGP11.phx.gbl>
<RX9pNPd...@cpmsftngxa10.phx.gbl>

<efEzOtjx...@TK2MSFTNGP09.phx.gbl>
<x2vchvpx...@cpmsftngxa10.phx.gbl>


| Subject: Re: Custom not found and HTTP status code

| Date: Wed, 10 Nov 2004 09:39:44 -0000
| Lines: 118


| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1437
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441

| Message-ID: <O6jD4kwx...@TK2MSFTNGP11.phx.gbl>


| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 213.52.137.34
| Path:

cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTFEED02.phx.gbl!tornado.fas
twebnet.it!tiscali!newsfeed1.ip.tiscali.net!news.glorb.com!hammer.uoregon.ed
u!enews.sgi.com!msrnewsc1!msrtrans!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.aspnet:274958
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet

Joerg Jooss

unread,
Nov 13, 2004, 5:20:21 AM11/13/04
to
Nick Horrocks wrote:
> Well that seems a really appauling oversight.
>
> I would be very happy for IIS to handle ALL 404 errors. However, if I
> want to trap errors and display a nice message to the user I have to
> abandon normal HTTP standards for 404 errors on any page with a .ASPX
> extension.

Silly idea: How about

Response.StatusCode = 404;

in your error page (assuming it's not a static HTML page)?

Cheers,

--
Joerg Jooss
www.joergjooss.de
ne...@joergjooss.de


0 new messages