【发布时间】:2012-09-09 22:47:34
【问题描述】:
有一个路由表包含
routes.MapRoute("404-PageNotFound", "{*url}", new { controller = "Error", action = "PageNotFound" });
web.config 有:
<customErrors mode="RemoteOnly">
<error statusCode="404" redirect="/Error/PageNotFound" />
</customErrors>
当没有路由匹配时,ErrorController 会被命中,并且错误视图使用以下方式呈现:
public ActionResult PageNotFound(ViewModelBase model)
{
return View(model);
}
响应的状态码是 200,但在这种情况下需要 404。有没有办法返回 http 代码 404 和客户错误页面?
【问题讨论】:
标签: asp.net-mvc asp.net-mvc-4 http-error