返回自定义错误页面
public ActionResult Details( string product)
{
....
if (productNotFound) {
// http://www.eidias.com/blog/2014/7/2/mvc-custom-error-pages
Response.Clear();
Response.TrySkipIisCustomErrors = true;
Response.Write(product + " product not exists");
Response.StatusCode = (int)HttpStatusCode.NotFound;
Response.End();
return null;
}
}