Redirect to 404error page YET return 404 Status Code

  • Thread starter Thread starter Pat Carden
  • Start date Start date
P

Pat Carden

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
 
In the PageNotFound page

I used

Response.StatusCode = 404

Doesn't seem to have the desired effect.

Pat
 
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.
 
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
 

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

Back
Top