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

前端 未结 7 632
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-12-01 00:12

    Try calling Response.End() to skip rendering...

    Response.Status = "404 Not Found";
    Response.StatusCode = 404;
    Response.End();
    return;
    

提交回复
热议问题