.Net MVC自定义错误页面在IIS8中不起作用

我有一个.NET MVC应用程序,我在使用IIS 8的服务器上运行自定义错误页面时遇到问题。在我的应用程序中,我正在捕捉并正确地抛出exception并在我的错误页面上显示一条消息,该页面是自定义的他们的违规行为。 当在调试中通过VS运行应用程序时以及在IIS(6.1)中的本地主机上配置站点时,这一切都在本地运行良好。

然后我将其部署到安装了IIS 8的服务器上。 最初我得到了令人讨厌的默认500错误页面: 默认500错误页面http://img202.imageshack.us/img202/1352/b8gr.png

在做了一点研究之后,我发现我可以将以下内容添加到web.config中,至少会把我的友好错误页面给我,虽然没有自定义文本:

   

我正在使用以下filter完成自定义错误消息:

 public class GlobalExceptionFilter : FilterAttribute, IExceptionFilter { public void OnException(ExceptionContext filterContext) { if (filterContext.HttpContext.IsCustomErrorEnabled && !filterContext.ExceptionHandled) { filterContext.ExceptionHandled = true; filterContext.HttpContext.Response.StatusCode = 500; string controllerName = (string)filterContext.RouteData.Values["controller"]; string actionName = (string)filterContext.RouteData.Values["action"]; HandleErrorInfo info = new HandleErrorInfo(filterContext.Exception, controllerName, actionName); IControllerFactory factory = ControllerBuilder.Current.GetControllerFactory(); ErrorController newController = factory.CreateController(filterContext.RequestContext, "Error") as ErrorController; filterContext.RouteData.Values["controller"] = "Error"; filterContext.Controller = newController; //Display specific error message for custom exception, otherwise generic message var model = new ErrorViewModel { Exception = info.Exception }; if (info.Exception.GetType() == typeof(RchiveException) || info.Exception.GetType().IsSubclassOf(typeof(RchiveException))) model.Message = info.Exception.Message; else model.Message = "An error occurred processing your request."; filterContext.Controller.ViewData = new ViewDataDictionary(model); string actionToCall = "Index"; if (filterContext.HttpContext.Request.IsAjaxRequest()) actionToCall = "IndexAjax"; filterContext.RouteData.Values["action"] = actionToCall; newController.ActionInvoker.InvokeAction(filterContext, actionToCall); } } } 

有任何想法吗?

我有同样的问题,实际上通过将我的配置更改为:

      

请将/ Error / E404更改为您的自定义错误路径。 然后我还补充说:

     

我也通过Plesk进行了一些更改,但我相信httpErrors行最终能够正常工作。