A controller is created for each of your requests. Let's take an example.
public class ExampleController : Controller{ public static userName; public void Action1(){
Now you can call the controller from the view that passes the username. Do not expect to get the username that you specified in the following query. it will return null. Thus, a new controller is created for each request. You do not instantiate the controller anywhere in MVC, as you install an object from a class. Itβs just that you donβt have a memory pointer for the controller object to call it the same way as with other objects.
Follow this link. There is a good explanation of the life cycle of an MVC controller.
ASP.Net MVC - Life Cycle Request
Hareendra Chamara Philips Apr 30 '14 at 9:29 2014-04-30 09:29
source share