如何使用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;

返回视图之前.