可能的重复:
如何配置 IIS 以使用自定义内容提供 404 响应? https://stackoverflow.com/questions/2551959/how-to-configure-iis-to-serve-my-404-response-with-my-custom-content
我想在 ASP.NET MVC 应用程序中提供用户友好的“未找到”页面,同时提供 404 状态代码。 (基于这个答案 https://stackoverflow.com/questions/2547430/how-to-return-proper-404-for-google-while-providing-user-friendly-content-to-the/2547471#2547471)
我已经有了如何捕获无效路由的机制,并且自定义 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 页面,不是我的用户友好内容)
如何在服务提供的结果中包含 404 状态代码Handle404
在提供内容的同时采取行动?
Setting
Response.TrySkipIisCustomErrors = true;
成功了。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)