Setting Response.StatusCode = 404
doesn't serve content under neither IE8 nor Chrome? It works in Mozilla though I find it strange!
Do the simplest of things - empty asp.net web application project with empty Default.aspx page. In Page_Load event use the following:
protected void Page_Load( object sender, EventArgs e )
{
Response.StatusCode = 404;
}
This effectively sets the status code of the current request to 404, no doubt about that. When rendering under IE8 or Chrome, or may be some other browsers as well - I haven't tested, the actual page doesn't show up at all. These browsers display their default 404 error pages (NOT default IIS custom errors). Example in IE8:
The webpage cannot be found
HTTP 404
Most likely causes:
•There might be a typing error in the address.
•If you clicked on a link, it may be out of date. ... and so on ...
What I really want to do though is to serve 404 error page with 404 error code which will actually tell the browser or the crawler or whoever that this page doesn't exist - not only to show some fancy custom error message with status message 200 OK.
Using fiddler shows that I am actually really serving the request, but the browser is totally ignoring it?!
My question - how can I set 404 status code and still render page content? Example - http://www.intel.com/invalidpage.wow. Using fiddler shows that this page is served with 404 status code.
The HTTP 200 OK success status response code indicates that the request has succeeded. A 200 response is cacheable by default. The meaning of a success depends on the HTTP request method: GET : The resource has been fetched and is transmitted in the message body.
OK indicates that the request succeeded and that the requested information is in the response. This is the most common status code to receive. Equivalent to HTTP status 206.
By default IE will show it's custom error page if the response for the error is less than a configurable amount. I believe the amount is 512 bytes, but I will try to find some confirmation on this. So all you need to do is put more content in your response.
EDIT: This blog post describes the limits. One of the comments shows the registry key settings for changing these values. The key is:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\ErrorThresholds
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With