Custom not found and HTTP status code

N

Nick Horrocks

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
 
J

Jim Cheshire [MSFT]

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
(e-mail address removed)

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

--------------------
| From: "Nick Horrocks" <[email protected]>
| 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: <[email protected]>
| 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
|
| 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
|
|
|
 
N

Nick Horrocks

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 said:
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
(e-mail address removed)

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

--------------------
| From: "Nick Horrocks" <[email protected]>
| 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: <[email protected]>
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: 213.52.137.34
| Path:
cpmsftngxa10.phx.gbl!TK2MSFTFEED02.phx.gbl!tornado.fastwebnet.it!tiscali!newsfeed1.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
|
| 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
|
|
|
 
J

Jim Cheshire [MSFT]

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
(e-mail address removed)

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

--------------------
| From: "Nick Horrocks" <[email protected]>
| References: <[email protected]>
<[email protected]>
| 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: <[email protected]>
| 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
|
|
| 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.
|
|
| | > 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
| > (e-mail address removed)
| >
| > This post is provided "AS-IS" with no warranties and confers no rights.
| >
| > --------------------
| > | From: "Nick Horrocks" <[email protected]>
| > | 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: <[email protected]>
| > | 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
| > |
| > | 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
| > |
| > |
| > |
| >
|
|
|
 
N

Nick Horrocks

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 said:
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
(e-mail address removed)

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

--------------------
| From: "Nick Horrocks" <[email protected]>
| References: <[email protected]>
<[email protected]>
| 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: <[email protected]>
| 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
|
|
| 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.
|
|
| | > 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
| > (e-mail address removed)
| >
| > This post is provided "AS-IS" with no warranties and confers no rights.
| >
| > --------------------
| > | From: "Nick Horrocks" <[email protected]>
| > | 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: <[email protected]>
| > | 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
| > |
| > | 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
| > |
| > |
| > |
| >
|
|
|
 
J

Jim Cheshire [MSFT]

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
(e-mail address removed)

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


--------------------
| From: "Nick Horrocks" <[email protected]>
| References: <[email protected]>
<[email protected]>
<[email protected]>
<[email protected]>
| 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: <[email protected]>
| 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
|
| 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.
|
|
|
|
| | > 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
| > (e-mail address removed)
| >
| > This post is provided "AS-IS" with no warranties and confers no rights.
| >
| > --------------------
| > | From: "Nick Horrocks" <[email protected]>
| > | References: <[email protected]>
| > <[email protected]>
| > | 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: <[email protected]>
| > | 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
| > |
| > |
| > | 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.
| > |
| > |
| > | | > | > 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
| > | > (e-mail address removed)
| > | >
| > | > This post is provided "AS-IS" with no warranties and confers no
| rights.
| > | >
| > | > --------------------
| > | > | From: "Nick Horrocks" <[email protected]>
| > | > | 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: <[email protected]>
| > | > | 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
| > | > |
| > | > | 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
| > | > |
| > | > |
| > | > |
| > | >
| > |
| > |
| > |
| >
|
|
|
 
J

Joerg Jooss

Nick said:
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,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top