How does ASP.NET MVC create controller instances for request? does it create different instances for different requests? if that so, does it mean ViewBag cannot be shared between actions in a controller although it is a member in controller?
1 Answer
Every request invokes its own controller instance. Therefore the ViewBag is local to every single request as well.
2 Comments
Shuping
OK, in detail, is the controller instance in a new thread? app domain? or process? and is there limitation defined by ASP.NET MVC or IIS that controlling the number of controller instances? Thanks.
Kirill Bestemyanov
It is invoked in one of the IIS threadpool threads. But why are you asking? What do you want to achieve?