ASP.NET Custom 404 Returning 200 OK Instead of 404 Not Found

前端 未结 7 639
Happy的楠姐
Happy的楠姐 2020-11-30 23:32

After trying to setup my site for Google Webmaster Tools I found that my Custom ASP.NET 404 page was not returning the 404 status code. It displayed the correct custom page

7条回答
  •  庸人自扰
    2020-11-30 23:57

    I had a similar problem I want to show a custom page as a 404 (which is ASPX) and it worked fine on localhost but as soon as a remote visitor connected they would get the generic IIS 404.

    The solution to this was to add

    Response.TrySkipIisCustomErrors = true;
    

    Before changing the Response.StatusCode.

    Found via Rick Strahl http://www.west-wind.com/weblog/posts/745738.aspx

提交回复
热议问题