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

redirect using addheader not working

P: 1
Hi I'm trying to use this bit of code that I found in a few places to redirect the page to a 404.html page...

Response.Status="404 Not Found"
Response.AddHeader "Location","http://sitename/404.html"

It doesn't seem to work but just returns an error. As far as the header is concerned it gives us exactly what we want but just doesn't do the redirect...

Using the same bit of code but with a 301 Permanently Moved does do the redirect but doesn't give us the proper header...

Response.Status="301 Permanently Moved"
Response.AddHeader "Location","http://sitename/404.html"

If I use the response.redirect method anywhere in the page the Status becomes a 302 automatically, hence the reason we are trying to use this code in the top example...

Can anyone help with this?
Mar 22 '11 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.