![](/img/trans.png)
[英]MVC 3: Where can I find default templates for DisplayForModel and EditorForModel?
[英]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();
}
在新的Microsoft.AspNet.Mvc中,找不到IController,並且Execute不是IController的一部分。
沒有一個- 控制器繼承自ControllerBase 。
在您的方案中,您需要解析對CommonController
類型的CommonController
而不是IController
,您可以使用該引用直接調用您的action方法。 就像是;
CommonController errorController = EngineContext.Current.Resolve<CommonController>();
errorController.PageNotFound();
return new EmptyResult();
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.