ASP.NET MVC Controller Lifecycle

前端 未结 3 469
醉梦人生
醉梦人生 2020-11-27 17:48

It\'s my understanding that the constructor for a controller is not called during each web request. Assuming this is true, what is the lifecycle of a controller? Is is \"con

3条回答
  •  情歌与酒
    2020-11-27 18:14

    I'm afraid, your understanding is wrong. A controller (which should be a very thin and lightweight class and must not have any session-outliving state) is actually constructed on the fly for each and every web request. How else could a controller instance be specific to a certain view?

    So there is no such thing as a "lifecycle" (other than that of the request)...

提交回复
热议问题