What is the size of the ViewData dictionary?

What is the size of the ViewData dictionary? I mean, when is it created for viewing and when is it destroyed?

Life cycle ViewDataDictionary.

+4
source share
1 answer

The ViewData dictionary created by the controller (more precisely, the first time you open it) is freed up after the rendering is complete. Getter excerpt:

public ViewDataDictionary ViewData { get { if (this._viewDataDictionary == null) { this._viewDataDictionary = new ViewDataDictionary(); } return this._viewDataDictionary; } set { this._viewDataDictionary = value; } } 

In principle, you can assume that ViewData will be available from the very beginning of the request inside your controller by rendering the view itself, and it will be released after the page finishes rendering.

+6
source

Source: https://habr.com/ru/post/1308881/


All Articles