C# C mvc4 ViewResult如何设置控制器和区域?

C# C mvc4 ViewResult如何设置控制器和区域?,c#,asp.net-mvc-4,C#,Asp.net Mvc 4,但我的位置不是搜索。错误方法在MyErrorController中。如何显式设置控制器MyErrorController 我的路径必须是~/Areas/Public/Views/MyError/Error.ascx {System.InvalidOperationException: The view 'Error' or its master was not found or no view engine supports the searched locations. The followi

但我的位置不是搜索。错误方法在MyErrorController中。如何显式设置控制器MyErrorController

我的路径必须是~/Areas/Public/Views/MyError/Error.ascx

{System.InvalidOperationException: The view 'Error' or its master was not found or no view engine supports the searched locations. The following locations were searched:
xxxxxxxx
在设置filterContext.Result之前,请尝试添加以下行:

"area" -> "Public"
"controller", "MyError"
"action" -> "Error";
在设置filterContext.Result之前,请尝试添加以下行:

"area" -> "Public"
"controller", "MyError"
"action" -> "Error";

你写的是ActionFilter吗?它没有定义视图属性。不,它是ExceptionContext。我更新了我的问题你在写什么?它没有定义视图属性。不,它是ExceptionContext。我更新了我的问题
filterContext.RouteData.DataTokens["area"] = "Public";
filterContext.RouteData.Values["controller"] = "MyError";
filterContext.RouteData.Values["action"] = "Error";