我怎样才能以另一种方式做到这一点?
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
.