how to get a controller instance in another controller
https://stackoverflow.com/a/32098348/3782855
As @mxmissile says in the comments to the accepted answer, you shouldn't new up the controller because it will be missing dependencies set up for IoC and won't have the HttpContext.
Instead, you should get an instance of your controller like this:
var controller = DependencyResolver.Current.GetService<ControllerB>();
controller.ControllerContext = new ControllerContext(this.Request.RequestContext, controller);
https://docs.microsoft.com/en-us/aspnet/web-api/overview/advanced/dependency-injection
how to get a controller instance in another controller的更多相关文章
- iOS 因为reason: 'Pushing the same view controller instance more than once is not supported而奔溃(下)
这个问题是什么意思呢,之前遇到过几次,但程序再次打开时没有问题,也就没有重视,今天又遇到了,无法忍受啊. 控制台报的错误是:"不支持多次推入相同的视图控制器实例". 什么原因造成的 ...
- 【原】push过快的错误 (Pushing the same view controller instance more than once is not supported)
今天在点击按钮push viewController 时,控制台报错: Terminating app due to uncaught exception 'NSInvalidArgumentExce ...
- iOS第八课——Navigation Controller和Tab bar Controller
今天我们要学习Navigation Controller和Tab bar Controller. Navigation Controller是iOS编程中比较常用的一种容器,用来管理多个视图控制器. ...
- MVC Controller 链接到 API Controller 以及反向链接
MVC Controller 链接到 API Controller 以及反向链接 问题 想创建一个从 ASP.NET MVC controller 到 ASP.NET Web API controll ...
- 坑:jmeter代理服务器录制脚本出现target controller is configured to "use recording Controller" but no such controller exists...
配置好代理服务器后,运行代理服务器 run 报错: target controller is configured to "use recording Controller" bu ...
- iOS 因为reason: 'Pushing the same view controller instance more than once is not supported而奔溃(上)
这个问题是什么意思呢,之前遇到过几次,但程序再次打开时没有问题,也就没有重视,今天又遇到了,无法忍受啊. 控制台报的错误是:"不支持多次推入相同的视图控制器实例". 什么原因造成的 ...
- Jmeter(十八)Logic Controllers 之 Random Controller and Random order Controller
Random Controller就比较简单了,完全随机!毫无章法. 毫无任何规律的运行. 还有一个Random order Controller,随机顺序控制器就像一个简单的控制器,它将最多执行一次 ...
- [水煮 ASP.NET Web API2 方法论](1-4)从 MVC Controller 链接到 API Controller 以及反向链接
问题 想创建一个从 ASP.NET MVC controller 到 ASP.NET Web API controller 的直接链接,或者反向链接. 解决方案 可以使用 System.Web.Htt ...
- I2C controller core之Bit controller(03)
FPGA proven, AISC proven, I2C controller core from OpenCores http://opencores.org/project,i2c Bit-co ...
随机推荐
- jquery动态生成html代码绑定事件
今天工作中需要在页面动态生成html代码,但发现新生成的代码的click事件失效了(非动态生成的代码已经绑定了click事件),于是在网上找了很多解决办法,很多都比较复杂,且使用的jquery都比较老 ...
- 【原】storm源码之mac os x编译twitter storm源码
twitter storm是由backtype公司创始人nathanmarz一手研发和开源的流计算(实时计算)框架,堪称实时计算领域的hadoop.nathanmarz也是在mac os x环境下开发 ...
- phantomjs学习之截图
1.创建pageload.js文件: pageload.js var page = require('webpage').create(); var address = 'https://www.ba ...
- easyui的datagrid无数据时下方滚动条不显示的解决办法(标题栏显示不完全)
easyui在写datagrid的时候标题栏有时候因为太多.太长所以无法显示所有的列,而且没数据的时候下方的滚动条是不显示的,这样就无法显示所有的列了.解决办法如下: onLoadSuccess: f ...
- Access 2010 VBA 读取 表中的数据
Option Compare Database Private Sub Command0_Click() Dim db Dim rs As Recordset Dim str As String Se ...
- php 正则表达式四,例子
PHP常用正则表达式汇总:http://bbs.php100.com/read-htm-tid-83266.html 1.非空匹配: .+ 2.浮点数匹配: ^\d+.\d{2}$ 3.手机号匹配: ...
- 如何在 window 上面输入特殊字符?
打开 字符映射表 程序 选中任意一个字符,它会在下方显示该字符的 16进制 转换16进制至10进制,并在输入法打开的状态下,按住 Alt 键输入 10 进制数值即可.
- shell判断文件/目录是否存在
https://www.cnblogs.com/37yan/p/6962563.html caution!!! if should be end with fi caution!!! there sh ...
- 洛谷 [BJOI2012]最多的方案
洛谷 这题是旁边同学介绍的,听他说记忆化搜索可以过... 不过我还是老老实实的想\(dp\)吧- 先看看数据范围,\(n\leq10^{18}\)相当于\(n \leq fib[86]\). 以前打\ ...
- PyMongo和MongoEngine
参见 http://stackoverflow.com/questions/5712857/pymongo-vs-mongoengine-for-django https://api.mongodb. ...