Question

In ASP.NET MVC3, when a view model is passed into a view using return View(myViewModel); it adds a definition to the ViewData dictionary, ViewData.Model, which holds myViewModel. In the view @model myViewModel will allow access of the view model data, alternatively you could also use ViewData.Model. Is the data that is passed into the ViewData dictionary serialized, or how is it stored for use in the model? I was under the impression ViewData was implemented by a caching strategy in server side memory.

Était-ce utile?

La solution

object Model is a property of ViewDataDictionary : IDictionary, ICollection>, IEnumerable>, IEnumerable. ViewDataDictionary is a property of ControllerBase.

Please check the ASP.NET MVC source code from here to find answers of your question.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top