473,384 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,384 software developers and data experts.

Custom not found and HTTP status code

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
6 2816
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

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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Sean Pinto | last post by:
My hosting company has an automatic redirect page called /missing/missing.php and I want to log all of the page not founds that result in a redirection to missing.php. I can't seem to find out how...
14
by: sinister | last post by:
I have some CGI programs that spit out error pages when the user enters illegal form input. These custom error pages, while informing the user of errors, are otherwise just standard web pages. ...
2
by: ninja_kornjaca | last post by:
Hello, I'm having a pretty strange problem and I'd appreciate if anyone could help me with it. I'm having a custom error page on my IIS. Specifically, I've written my own ASP (classic ASP)...
6
by: Suzanne | last post by:
Hi all, I really hope someone out there can help me as I've been tearing my hair out on this one for a good while and I'm getting really frustrated now! My problem is this - my custom...
0
by: webmaster | last post by:
Hi all, I'm tearing my hair out with this one. I have successfully implemented by own RadioButtonList in order to provide additional functionality and a DIV rather than TABLE-based layout in...
4
by: Ron | last post by:
Hi, I have created a custom membership provider that i use to create certain types of user accounts that only require a User Name and Password nothing else this code below works great if i use...
5
by: Blue | last post by:
We have a custom word processing type editor built with C# and .NET 2.0 and we need to support typing in languages other than English. I want to be able to use the Windows IME to enter in text...
15
by: rizwanahmed24 | last post by:
Hello i have made a custom control. i have placed a panel on it. I want this panel to behave just like the normal panel. The problem i was having is that the panel on my custom control doesnt...
0
by: Nithi Gurusamy | last post by:
I have generated a Web-Service-Proxy (Add Web Reference) within VS. This proxy class is based on WebServicesClientProtocol of WSE 3.0. I want to add some custom HTTP Headers to the envelop before...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.