我正在开发一个 MVC 5 互联网应用程序,并且有一个关于将 an 传递object
给 shared的问题view
。
我在共享文件夹中有一个view
调用。CustomError.cshtml
这view
具有以下模型类型:@model CanFindLocation.ViewModels.CustomErrorViewModel
如何从 a 中的函数将类型的对象传递CanFindLocation.ViewModels.CustomErrorViewModel
给 this ?view
protected override void OnException(ExceptionContext filterContext)
controller
这是我的代码:
protected override void OnException(ExceptionContext filterContext)
{
Exception e = filterContext.Exception;
if (e is HttpRequestValidationException)
{
filterContext.ExceptionHandled = false;
customErrorViewModel = customErrorService.GetDefaultCustomError(customErrorType, "Test message.");
RedirectToAction("CustomError", customErrorViewModel);
}
}
没有显示,而是view
调用了以下函数:
protected void Application_Error(object sender, EventArgs e)
提前致谢。