如何使用asp.net MVC视图返回404 [英] How to return 404 with asp.net mvc view
本文介绍了如何使用asp.net MVC视图返回404的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何实现以下功能?
我的控制器:
if (something == null)
{
//return the view with 404 http header
return View();
}
//return the view with 200 http header
return View();
推荐答案
只需编写
Response.StatusCode = 404;
返回视图之前.
这篇关于如何使用asp.net MVC视图返回404的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文