【发布时间】:2011-02-02 14:31:16
【问题描述】:
可能重复:
How to configure IIS to serve my 404 response with my custom content?
我想在我的 ASP.NET MVC 应用程序中提供一个用户友好的“未找到”页面,同时提供 404 状态代码。 (基于this answer)
我已经掌握了如何捕获无效路由的机制,并且自定义 404 页面由我的 ErrorController/Handle404 操作提供。
我目前对Handle404的实现:
public ActionResult Handle404()
{
Response.StatusCode = 404;
return View("NotFound");
}
目前,IIS 将页面作为404 - File or directory not found.
The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable. 提供服务(标准 IIS 页面,不是我的用户友好内容)
如何在Handle404 操作提供的结果中包含 404 状态代码,同时仍然提供内容?
【问题讨论】:
标签: c# asp.net-mvc iis http-status-code-404