标签:not request factory var one log www html stc
一、激活实例代码1
这是在Global文件中使用
var routeData = new RouteData(); routeData.Values["controller"] = "Sys"; routeData.Values["action"] = "NotFound"; var requestContext = new RequestContext(new HttpContextWrapper(httpContext), routeData); var controller = ControllerBuilder.Current.GetControllerFactory().CreateController(requestContext, "Sys") as SysController; //controller.ViewData.Model=model; (controller as IController).Execute(requestContext); ControllerBuilder.Current.GetControllerFactory().ReleaseController(controller);
激活实例代码2
这是在controller中的情况下
string controllerName = this.RequestContext.RouteData.Controller; IControllerFactory controllerFactory = ControllerBuilder.Current.GetControllerFactory(); IController controller = controllerFactory.CreateController(this.RequestContext, controllerName); controller.Execute(this.RequestContext);
实例代码3,激活指定controller中的action并返回视图到当前上下文:
//输出指定controller下的内容 RouteData routeData = new RouteData(); routeData.Values.Add("controller", "ViewOne"); routeData.Values.Add("action", "TempTwo"); routeData.Values.Add("name", "zhangsan"); IController one = new ViewOneController(); one.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));
更多:
http://www.cnblogs.com/tianma3798/p/3958575.html
标签:not request factory var one log www html stc
原文地址:http://www.cnblogs.com/tianma3798/p/6231907.html