I found an article that explains in further detail how to make the "404 Not Found" show-up even when using a custom error page. You need to add <% response.status = "404 Not Found" %> to your custom 404 webpage and the appropriate status code is returned.
http://web-sniffer.net/ tool.
'Here is a link to the article http://www.mcanerin.com/EN/articles/301-redirect-404-error.asp
please dont use response.status = "404 Not Found"
its at least against all globalization rules. I would suggest to put the code in load event ( thats where everybody is expecting it) and use the Statuscode
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Response.StatusCode = "404"
End Sub
ps: i have no idea why but i can not use IE7 to comment your blog
http://
said
I would report the bug to CommunityServer.org or send me an email at steve AT orcsweb.com. I'll report the problem. Can you tell me what version of OS you are running? Do you get any errors? What happens when you try, a popup box? JavaScript error?
Also – Hannes, the StatusCode is of type Int32, so your VB.NET example won't compile.
Phil Winstanley
said
It's bad practice to use any kind of dynamic page as your error page – if ASP.NET is failing or something in your request stack is erroring the error page could also cause it to error.
Instead point to a .html file on disk with appropriate links.
Oh and it's the Technorati script which is breaking the comments in IE7, I had exactly the same issue.
Phil – it's all well and good pointing to a static and generic error page, but the whole point of custom errors in ASP.NET is exactly to use dynamic pages. Why else would we have a Server.GetLastError()?
Simply pointing to a generic error page in that instance would also not give you the appropriate error logging and notification that you would have when serving up a dynamic error page.
Also – taking your argument a step further, one might as well say: "What if IIS is down…?"… 😉
steve schofield
said
Thanks Plip for telling me how to solve the issue. I removed the section, hopefully this will allow people post comments. I didn't find much on this topic, so I thought I would post what worked for one person. the additional information will help people looking for a solution.
steve schofield
said
I disagree about not using a dynamic page for a 404 / 500 error. This helps many times to make a site better, by logging errors. I suppose it depends on what site, but for the ones I've done, having a dynamic error page makes more sense.
9 Comments
Hannes Preishuber said
please dont use response.status = "404 Not Found"
its at least against all globalization rules. I would suggest to put the code in load event ( thats where everybody is expecting it) and use the Statuscode
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
Response.StatusCode = "404"
End Sub
ps: i have no idea why but i can not use IE7 to comment your blog
http:// said
I would report the bug to CommunityServer.org or send me an email at steve AT orcsweb.com. I'll report the problem. Can you tell me what version of OS you are running? Do you get any errors? What happens when you try, a popup box? JavaScript error?
Wim Hollebrandse said
Err…Steve, surely using the HttpStatusCode enumeration is better than setting the Status string:
Response.StatusCode = (int)HttpStatusCode.NotFound;
Also – Hannes, the StatusCode is of type Int32, so your VB.NET example won't compile.
Phil Winstanley said
It's bad practice to use any kind of dynamic page as your error page – if ASP.NET is failing or something in your request stack is erroring the error page could also cause it to error.
Instead point to a .html file on disk with appropriate links.
Oh and it's the Technorati script which is breaking the comments in IE7, I had exactly the same issue.
Wim Hollebrandse said
Phil – it's all well and good pointing to a static and generic error page, but the whole point of custom errors in ASP.NET is exactly to use dynamic pages. Why else would we have a Server.GetLastError()?
Simply pointing to a generic error page in that instance would also not give you the appropriate error logging and notification that you would have when serving up a dynamic error page.
Also – taking your argument a step further, one might as well say: "What if IIS is down…?"… 😉
steve schofield said
Thanks Plip for telling me how to solve the issue. I removed the section, hopefully this will allow people post comments. I didn't find much on this topic, so I thought I would post what worked for one person. the additional information will help people looking for a solution.
steve schofield said
I disagree about not using a dynamic page for a 404 / 500 error. This helps many times to make a site better, by logging errors. I suppose it depends on what site, but for the ones I've done, having a dynamic error page makes more sense.
Wim Hollebrandse said
Aye Steve – my point exactly.
weblogs.asp.net said
How to fix http headers always return 200 code.. Dandy 🙂