By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 2,225 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

Custom not found and HTTP status code

P: n/a
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
Nov 18 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
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
ja******@online.microsoft.com

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

--------------------
| From: "Nick Horrocks" <ni**********@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*************@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.ne t!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
|
| 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
|
|
|

Nov 18 '05 #2

P: n/a

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]" <ja******@online.microsoft.com> wrote in message
news:RX*************@cpmsftngxa10.phx.gbl...
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
ja******@online.microsoft.com

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

--------------------
| From: "Nick Horrocks" <ni**********@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*************@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.ne t!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
|
| 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
|
|
|

Nov 18 '05 #3

P: n/a
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
ja******@online.microsoft.com

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

--------------------
| From: "Nick Horrocks" <ni**********@hotmail.com>
| References: <OP*************@TK2MSFTNGP11.phx.gbl>
<RX*************@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: <ef**************@TK2MSFTNGP09.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 213.52.137.34
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP09
phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.aspnet:274629
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
|
| 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]" <ja******@online.microsoft.com> wrote in message
| news:RX*************@cpmsftngxa10.phx.gbl...
| > 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
| > ja******@online.microsoft.com
| >
| > This post is provided "AS-IS" with no warranties and confers no rights.
| >
| > --------------------
| > | From: "Nick Horrocks" <ni**********@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*************@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.ne t!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
| > |
| > | 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
| > |
| > |
| > |
| >
|
|
|

Nov 18 '05 #4

P: n/a
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]" <ja******@online.microsoft.com> wrote in message
news:x2**************@cpmsftngxa10.phx.gbl...
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
ja******@online.microsoft.com

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

--------------------
| From: "Nick Horrocks" <ni**********@hotmail.com>
| References: <OP*************@TK2MSFTNGP11.phx.gbl>
<RX*************@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: <ef**************@TK2MSFTNGP09.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 213.52.137.34
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP09 phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.aspnet:274629 | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
|
| 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]" <ja******@online.microsoft.com> wrote in message
| news:RX*************@cpmsftngxa10.phx.gbl...
| > 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
| > ja******@online.microsoft.com
| >
| > This post is provided "AS-IS" with no warranties and confers no rights. | >
| > --------------------
| > | From: "Nick Horrocks" <ni**********@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*************@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.ne t!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
| > |
| > | 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
| > |
| > |
| > |
| >
|
|
|

Nov 18 '05 #5

P: n/a
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
ja******@online.microsoft.com

This post is provided "AS-IS" with no warranties and confers no rights.
--------------------
| From: "Nick Horrocks" <ni**********@hotmail.com>
| References: <OP*************@TK2MSFTNGP11.phx.gbl>
<RX*************@cpmsftngxa10.phx.gbl>
<ef**************@TK2MSFTNGP09.phx.gbl>
<x2**************@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: <O6**************@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 213.52.137.34
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT FEED02.phx.gbl!tornado.fas
twebnet.it!tiscali!newsfeed1.ip.tiscali.net!news.g lorb.com!hammer.uoregon.ed
u!enews.sgi.com!msrnewsc1!msrtrans!TK2MSFTNGP08.ph x.gbl!TK2MSFTNGP11.phx.gbl
| Xref: cpmsftngxa10.phx.gbl microsoft.public.dotnet.framework.aspnet:274958
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| 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]" <ja******@online.microsoft.com> wrote in message
| news:x2**************@cpmsftngxa10.phx.gbl...
| > 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
| > ja******@online.microsoft.com
| >
| > This post is provided "AS-IS" with no warranties and confers no rights.
| >
| > --------------------
| > | From: "Nick Horrocks" <ni**********@hotmail.com>
| > | References: <OP*************@TK2MSFTNGP11.phx.gbl>
| > <RX*************@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: <ef**************@TK2MSFTNGP09.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.framework.aspnet
| > | NNTP-Posting-Host: 213.52.137.34
| > | Path:
| >
|
cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFT NGP08.phx.gbl!TK2MSFTNGP09
| > phx.gbl
| > | Xref: cpmsftngxa10.phx.gbl
| microsoft.public.dotnet.framework.aspnet:274629
| > | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
| > |
| > |
| > | 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]" <ja******@online.microsoft.com> wrote in message
| > | news:RX*************@cpmsftngxa10.phx.gbl...
| > | > 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
| > | > ja******@online.microsoft.com
| > | >
| > | > This post is provided "AS-IS" with no warranties and confers no
| rights.
| > | >
| > | > --------------------
| > | > | From: "Nick Horrocks" <ni**********@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*************@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.ne t!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
| > | > |
| > | > | 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
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|

Nov 18 '05 #6

P: n/a
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
Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.