473,473 Members | 2,102 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Redirect to 404error page YET return 404 Status Code

I'm trying to provide a better user experience by redirecting my users to a
"Page Not Found" page, using a Custom Errors directive in Web.Config.

The problem is I need to return a 404 error code to the browser (or spider)
before redirecting. Now, the system is reporting a status code of 302 on
the original page and a 200 status code on the error page.

I would like to use Google Sitemaps and they require this, plus I have a
linkchecking service that is unable to detect the redirect.

Can someone tell me how to accomplish this? I tried with the following code
in the "Page Not Found" page, but it didn't yield the desired result.

Thanks a lot!

Pat
Nov 20 '05 #1
7 2877

Response.StatusCode = 404;
Jason Kester
Expat Software Consulting Services
http://www.expatsoftware.com/

Nov 20 '05 #2
Pat where is the code you said you tried?
Patrick

"Pat Carden" <pc*****@bellsouth.nospam.net> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
I'm trying to provide a better user experience by redirecting my users to a "Page Not Found" page, using a Custom Errors directive in Web.Config.

The problem is I need to return a 404 error code to the browser (or spider) before redirecting. Now, the system is reporting a status code of 302 on
the original page and a 200 status code on the error page.

I would like to use Google Sitemaps and they require this, plus I have a
linkchecking service that is unable to detect the redirect.

Can someone tell me how to accomplish this? I tried with the following code in the "Page Not Found" page, but it didn't yield the desired result.

Thanks a lot!

Pat

Nov 20 '05 #3
In the PageNotFound page

I used

Response.StatusCode = 404

Doesn't seem to have the desired effect.

Pat
"Patrick.O.Ige" <pa********@optusnet.com.au> wrote in message
news:OZ**************@TK2MSFTNGP12.phx.gbl...
Pat where is the code you said you tried?
Patrick

"Pat Carden" <pc*****@bellsouth.nospam.net> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
I'm trying to provide a better user experience by redirecting my users to

a
"Page Not Found" page, using a Custom Errors directive in Web.Config.

The problem is I need to return a 404 error code to the browser (or

spider)
before redirecting. Now, the system is reporting a status code of 302 on
the original page and a 200 status code on the error page.

I would like to use Google Sitemaps and they require this, plus I have a
linkchecking service that is unable to detect the redirect.

Can someone tell me how to accomplish this? I tried with the following

code
in the "Page Not Found" page, but it didn't yield the desired result.

Thanks a lot!

Pat


Nov 20 '05 #4
Have you tried using :

<customErrors mode="RemoteOnly" defaultRedirect="~/error.aspx">
<error statusCode="404" redirect="~/PageNotFound.aspx" />
</customErrors>

in your web.config ?

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Pat Carden" <pc*****@bellsouth.nospam.net> wrote in message
news:OS**************@TK2MSFTNGP11.phx.gbl...
In the PageNotFound page

I used

Response.StatusCode = 404

Doesn't seem to have the desired effect.

Pat
"Patrick.O.Ige" <pa********@optusnet.com.au> wrote in message
news:OZ**************@TK2MSFTNGP12.phx.gbl...
Pat where is the code you said you tried?
Patrick

"Pat Carden" <pc*****@bellsouth.nospam.net> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
I'm trying to provide a better user experience by redirecting my users to

a
"Page Not Found" page, using a Custom Errors directive in Web.Config.

The problem is I need to return a 404 error code to the browser (or

spider)
before redirecting. Now, the system is reporting a status code of 302 on
the original page and a 200 status code on the error page.

I would like to use Google Sitemaps and they require this, plus I have a
linkchecking service that is unable to detect the redirect.

Can someone tell me how to accomplish this? I tried with the following

code
in the "Page Not Found" page, but it didn't yield the desired result.

Thanks a lot!

Pat



Nov 20 '05 #5
Yes that's what I'm using but it return a status code 302 instead of a 404
and then a 200 when it hits the error page.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:uK**************@TK2MSFTNGP11.phx.gbl...
Have you tried using :

<customErrors mode="RemoteOnly" defaultRedirect="~/error.aspx">
<error statusCode="404" redirect="~/PageNotFound.aspx" />
</customErrors>

in your web.config ?

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Pat Carden" <pc*****@bellsouth.nospam.net> wrote in message
news:OS**************@TK2MSFTNGP11.phx.gbl...
In the PageNotFound page

I used

Response.StatusCode = 404

Doesn't seem to have the desired effect.

Pat
"Patrick.O.Ige" <pa********@optusnet.com.au> wrote in message
news:OZ**************@TK2MSFTNGP12.phx.gbl...
Pat where is the code you said you tried?
Patrick

"Pat Carden" <pc*****@bellsouth.nospam.net> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
I'm trying to provide a better user experience by redirecting my users
to
a
"Page Not Found" page, using a Custom Errors directive in Web.Config.

The problem is I need to return a 404 error code to the browser (or
spider)
before redirecting. Now, the system is reporting a status code of 302
on
the original page and a 200 status code on the error page.

I would like to use Google Sitemaps and they require this, plus I have
a
linkchecking service that is unable to detect the redirect.

Can someone tell me how to accomplish this? I tried with the following
code
in the "Page Not Found" page, but it didn't yield the desired result.

Thanks a lot!

Pat



Nov 20 '05 #6
Pat but if it returned status code 302 did it redirect you to the page you
specified?
Maybe check your IIS settings and see.
Patrick

"Pat Carden" <pc*****@bellsouth.nospam.net> wrote in message
news:eM**************@TK2MSFTNGP15.phx.gbl...
Yes that's what I'm using but it return a status code 302 instead of a 404
and then a 200 when it hits the error page.

"Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:uK**************@TK2MSFTNGP11.phx.gbl...
Have you tried using :

<customErrors mode="RemoteOnly" defaultRedirect="~/error.aspx">
<error statusCode="404" redirect="~/PageNotFound.aspx" />
</customErrors>

in your web.config ?

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Pat Carden" <pc*****@bellsouth.nospam.net> wrote in message
news:OS**************@TK2MSFTNGP11.phx.gbl...
In the PageNotFound page

I used

Response.StatusCode = 404

Doesn't seem to have the desired effect.

Pat
"Patrick.O.Ige" <pa********@optusnet.com.au> wrote in message
news:OZ**************@TK2MSFTNGP12.phx.gbl...
Pat where is the code you said you tried?
Patrick

"Pat Carden" <pc*****@bellsouth.nospam.net> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
> I'm trying to provide a better user experience by redirecting my users> to
a
> "Page Not Found" page, using a Custom Errors directive in Web.Config.
>
> The problem is I need to return a 404 error code to the browser (or
spider)
> before redirecting. Now, the system is reporting a status code of 302> on
> the original page and a 200 status code on the error page.
>
> I would like to use Google Sitemaps and they require this, plus I have> a
> linkchecking service that is unable to detect the redirect.
>
> Can someone tell me how to accomplish this? I tried with the following code
> in the "Page Not Found" page, but it didn't yield the desired result.
>
> Thanks a lot!
>
> Pat
>
>



Nov 20 '05 #7
Could that be because the page is found and you're being redirected ?

;-)

10.3.3 302 Found :
http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Pat Carden" <pc*****@bellsouth.nospam.net> wrote in message
news:eM**************@TK2MSFTNGP15.phx.gbl...
Yes that's what I'm using but it return a status code 302 instead of a 404 and then a
200 when it hits the error page. "Juan T. Llibre" <no***********@nowhere.com> wrote in message
news:uK**************@TK2MSFTNGP11.phx.gbl...
Have you tried using :

<customErrors mode="RemoteOnly" defaultRedirect="~/error.aspx">
<error statusCode="404" redirect="~/PageNotFound.aspx" />
</customErrors>

in your web.config ?

Juan T. Llibre, ASP.NET MVP
ASP.NET FAQ : http://asp.net.do/faq/
ASPNETFAQ.COM : http://www.aspnetfaq.com/
Foros de ASP.NET en Español : http://asp.net.do/foros/
======================================
"Pat Carden" <pc*****@bellsouth.nospam.net> wrote in message
news:OS**************@TK2MSFTNGP11.phx.gbl...
In the PageNotFound page

I used

Response.StatusCode = 404

Doesn't seem to have the desired effect.

Pat
"Patrick.O.Ige" <pa********@optusnet.com.au> wrote in message
news:OZ**************@TK2MSFTNGP12.phx.gbl...
Pat where is the code you said you tried?
Patrick

"Pat Carden" <pc*****@bellsouth.nospam.net> wrote in message
news:Oe**************@tk2msftngp13.phx.gbl...
> I'm trying to provide a better user experience by redirecting my users to
a
> "Page Not Found" page, using a Custom Errors directive in Web.Config.
>
> The problem is I need to return a 404 error code to the browser (or
spider)
> before redirecting. Now, the system is reporting a status code of 302 on
> the original page and a 200 status code on the error page.
>
> I would like to use Google Sitemaps and they require this, plus I have a
> linkchecking service that is unable to detect the redirect.
>
> Can someone tell me how to accomplish this? I tried with the following
code
> in the "Page Not Found" page, but it didn't yield the desired result.
>
> Thanks a lot!
>
> Pat
>
>



Nov 20 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
by: Andrew Chalk | last post by:
In a Python script running under CGI, can I programatically redirect the program to another page. Assume that I have a static HTML page that I want displayed (e.g. index.htm). Other than 'print...
3
by: Don Miller | last post by:
I used a Response.Redirect "page.asp" as the last command in ASP code that processes a submitted form from an Adobe PDF form (using HTML format). For some reason, if there is any linked file...
7
by: Mike | last post by:
Hi How can I make it so my web hosting server will redirect all hits to non existant web pages to the main index.html page? Thanks in advance
9
by: Glen | last post by:
I'm writing a console utility to download specific files from web sites based on the command line options. In most cases, I can trap the 404 error when the file isn't available because the...
4
by: Shahriar | last post by:
Hi I am trying to figure whether a page exist in the server or not without parsing the document for a 404 or a for a "error". I am using the webbrower control. Does that return a status code...
12
by: gigi | last post by:
How to send more than one value using response redirect? For example i can send one like this response.Redirect "pregled.asp?ime=" & strUserName but how to send two or more values? I tried...
3
by: new214 | last post by:
heya all, ive got abit of a problem. Im doin a system in asp- which works on a test server- but when on moving my application to a development server- it throws the following error messages where I...
56
by: UKuser | last post by:
Hi, I'm not sure if this can be done as I've searched the web and this forum. I am using an online merchant provider and I must post certain variables to their webforms through a form on my...
1
by: zizi2 | last post by:
I have a form that I want to redirect to another page after clicking the submit button. It works well (please see the code below) except that it cancells my pop-up message, it goes the redirected...
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...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.