Reputation: 18308
Does more than one instance of a controller get created per App-Domain? If so under what conditions?
Upvotes: 5
Views: 3167
Reputation: 13091
As Jakub has said, using the default controller factory, you get one controller instance per request.
Always ensure that the controllers are stateless - in the event that your application is ever run on a web farm or, say, Windows Azure, you can't even guarantee that subsequent requests are served by the same machine.
Instead, put any data that must be preserved across requests into Session State (or use your back-end data store).
Upvotes: 2
Reputation: 46008
A new instance of a controller is created for each request by MVC, so you may end up with multiple instances running on different threads.
There is nothing stopping you from creating multiple instances yourself.
The controller should be stateless.
Upvotes: 8