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 ...
随机推荐
- Android测试:从零开始1——简介
参考文档:https://developer.android.com/training/testing/start/index.html 测试分类 使用android studio进行测试,首先需要先 ...
- python之进制转换
Python中二进制是以0b开头的: 例如: 0b11 则表示十进制的3 8进制是以0开头的: 例如: 011则表示十进制的9 16进制是以0x开头的: 例如: 0x11则表示十进制 ...
- c++ 指针(不断更新)
c++指针只能说博大精深,在用的时候感觉好晕 1.指针类型转换 /* 在指针的强制类型转换:ptr1=(TYPE*)ptr2中,如果sizeof(ptr2的类型)大于sizeof(ptr1的类型), ...
- HDU 5658 CA Loves Palindromic(回文树)
CA Loves Palindromic Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 262144/262144 K (Java/O ...
- GRPC使用错误排查记录
1. 编译报错 f.fr.SetReuseFrames undefined (type *http2.Framer has no field or method SetReuseFrames) 该问题 ...
- 巨蟒python全栈开发flask3
首先,我们新建一个项目: 这个时候,我们调用ab函数,可以在所有的模板中使用. 上边是一个特殊装饰器, 1.flask特殊装饰器 下面说几个特殊的装饰器 再请求之前的装饰器 运行: 这个时候,服务端打 ...
- https://blog.newrelic.com/2014/05/02/25-php-developers-follow-online/
w https://blog.newrelic.com/2014/05/02/25-php-developers-follow-online/ 1. Rob Allen. Zend Framework ...
- python中counter()记数
一:定义一个list数组,求数组中每个元素出现的次数 如果用Java来实现,是一个比较复杂的,需要遍历数组list. 但是Python很简单:看代码 a = [1,4,2,3,2,3,4,2] fro ...
- Python SQLAlchemy基本操作和常用技巧(包含大量实例,非常好)
https://www.jb51.net/article/49789.htm 首先说下,由于最新的 0.8 版还是开发版本,因此我使用的是 0.79 版,API 也许会有些不同.因为我是搭配 MySQ ...
- Redis资料汇总(转)
原文:Redis资料汇总专题 很多朋友反映,说NoSQLFan上的资料不少,但是要找到自己实用的太难,于是萌生做这样一个专题的想法.通过将不同NoSQL产品从入门到精通的各种资料进行汇总,希望能够让大 ...