ASP.NET custom 404 returning 200 OK instead of 404 Not Found
1. Edit the web.config for custom errors:
2. Add a 404.aspx page and set the status code to 404.<customErrors mode="On"> <error statusCode="404" redirect="~/404.aspx"/> </customErrors>
Now, if I go to a page extension that is processed by ASP.NET and does not exist, my "Live HTTP header" addon in Firefox shows a 404. Here is the header:public partial class _404 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { Response.StatusCode = 404; } }
HTTP/1.1 404 Not Found Server: Microsoft-IIS/5.1 Date: Sun, 07 Dec 2008 06:04:13 GMT X-Powered-By: ASP.NET X-AspNet-Version: 2.0.50727 Cache-Control: private Content-Type: text/html; charset=utf-8 Content-Length: 533
Commentaires