I am using ViewModel classes in order to structure data being populated inside of a controller.
My questions is now where exactly is data of a @model stored after being populated via asp mvc controller.
Software Engineering Stack Exchange is a question and answer site for professionals, academics, and students working within the systems development life cycle. It only takes a minute to sign up.Sign up to join this community
In MVC, the model (that is an instance of a model class) is nothing more than an ordinary object. It is initialized by the controller which passes it to MVC's engine which, in turn, uses it when generating the final result from a view.
If you're asking whether it is stored on the stack or on the heap, the response is: on the heap.
Instance variables for a reference type are always on the heap.
If you're asking whether it is stored in memory or on a hard disk, the response is: it depends. In general, it will be in memory, unless the operating system runs out of memory and decides to move it to the pagefile (chances for this to happen are slim).
If you're asking how should you access the model once initialized (i.e. where to find the instance of the model class), just keep a reference to it within the controller itself.