【发布时间】:2018-05-24 17:24:26
【问题描述】:
当我收到一个不存在的路由请求时,在我的 mvc 应用程序中, 我清除服务器错误并重定向到我的 ErrorController(代码在 Global.asax.cs Application_Error):
Response.Clear();
HttpContext.Current.Response.TrySkipIisCustomErrors = true;
Server.ClearError();
var routeData = new RouteData();
routeData.Values.Add("controller", "Error");
routeData.Values.Add("action", "HttpError404");
IController errorController = new ErrorController();
errorController.Execute(new RequestContext(
new HttpContextWrapper(Context), routeData));
并且动作返回一个视图:
public ActionResult HttpError404(Exception error)
{
Response.StatusCode = 404;
if (Request.IsAjaxRequest())
{
return Content("404 not found");
}
return View();
}
问题是当 chrome 和 ff(不在边缘)的 web.config 中有 compilation debug="true" 时,404 页面显示为源(纯 html)
【问题讨论】:
-
compilation与此无关...检查是否为您启用了浏览器链接,禁用并检查
标签: asp.net-mvc