【发布时间】:2013-08-08 12:28:21
【问题描述】:
我怎样才能以另一种方式做到这一点?
public ActionResult SomeAction(int id)
{
try
{
var model = GetMyModel(id);
return View(model);
}
catch(Exception e)
{
var notFoundViewModel = new NotFoundViewModel { Some Properties };
return View("~/Views/Shared/NotFound.cshtml", notFoundViewModel);
}
}
url Controller/SomeAction/NotFoundId 将抛出异常。我讨厌在项目中有这样的东西:~/Views/Shared/NotFound.cshtml。
【问题讨论】:
-
只返回 404?毕竟找不到。
标签: c# asp.net-mvc