asp.net 增加404页面(非302、200)

由于项目改版,导致产生了许多死链,但是之前的404页面都是在Application_Error中Response.Redicet()到404页面,但是这样子是302跳转,导致搜索引擎认为网页不是死链而是正常的链接,所以应该返回400状态码给搜索引擎。网上的方法个人觉得太过繁杂。

代码:在Application_Error中

1 Response.StatusCode = 404;
2 Response.WriteFile(Server.MapPath("/404.html"));
3 Response.End();
View Code

静待效果!

猜你喜欢

转载自www.cnblogs.com/mapleFlying/p/9257534.html