[英]Where can I find IController for MVC 6?
protected virtual IActionResult InvokeHttp404()
{
IController errorController = EngineContext.Current.Resolve<CommonController>();
var routeData = new RouteData();
routeData.Values.Add("controller", "Common");
routeData.Values.Add("action", "PageNotFound");
errorController.Execute(new RequestContext(HttpContext, routeData));
return new EmptyResult();
}
In the new Microsoft.AspNet.Mvc, IController could not be found and Execute is not part of IController. 在新的Microsoft.AspNet.Mvc中,找不到IController,并且Execute不是IController的一部分。
There isn't one - Controller inherits from ControllerBase . 没有一个- 控制器继承自ControllerBase 。
In your scenario, you would need to resolve a reference to a type of CommonController
rather than IController
, with which you can call your action method directly. 在您的方案中,您需要解析对CommonController
类型的CommonController
而不是IController
,您可以使用该引用直接调用您的action方法。 Something like; 就像是;
CommonController errorController = EngineContext.Current.Resolve<CommonController>();
errorController.PageNotFound();
return new EmptyResult();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.