我试图从MVC4移动应用程序显示一个自定义错误页面,但不断显示“Error Loading Page”黄色消息而不是我的自定义页面。MVC4 jQueryMobile不会显示自定义错误页面OnException
我一直在使用下面上的操作,控制器没有成功
[HandleError(ExceptionType = typeof(SqlException), View = "DatabaseError")]
我也试图重写我的基本控制器的onException的方法HandleErrorAttribute尝试,但这个还没有出现有任何影响。
protected override void OnException(ExceptionContext filterContext)
{
if (filterContext == null)
base.OnException(filterContext);
Logger.LogException(filterContext.Exception);
if (filterContext.Exception is SqlException)
{
filterContext.Result = new ViewResult { ViewName = "DatabaseError" };
}
if (filterContext.Exception is SomeOtherException)
{
filterContext.Result = new ViewResult { ViewName = "Error" };
}
if (filterContext.HttpContext.IsCustomErrorEnabled)
{
filterContext.ExceptionHandled = true;
filterContext.Result.ExecuteResult(this.ControllerContext);
}
}
如果我试图对他们具有预期的非jQueryMobile MVC4应用这些方法,只是没有在我的移动应用程序!
任何人都知道为什么以及如何使这项工作?