Does more than one instance of a controller get created per App-Domain? If so under what conditions?
In Spring MVC, we can create multiple controllers at a time. It is required to map each controller class with @Controller annotation.
A controller is responsible for controlling the way that a user interacts with an MVC application. A controller contains the flow control logic for an ASP.NET MVC application. A controller determines what response to send back to a user when a user makes a browser request.
You could instantiate a new context in the repository, but then if you used multiple repositories in one controller, each would end up with a separate context. Later you'll use multiple repositories in the Course controller, and you'll see how a unit of work class can ensure that all repositories use the same context.
Yes You can use multiple View in one Controller. so I have one controller and 2 views. Welcome to StackOverflow! While answers are always appreciated, this question was asked 6 years ago, and already had an accepted solution.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With