开发者

What is the scope of ViewData Dictionary?

What is the scope of ViewData Dictionary?I mean when It Creates for a View & when it destroys?

Lifecycl开发者_JAVA技巧e of ViewDataDictionary.


The ViewData dictionary is created by the controller (more precisely the first time you access it) is released after the view finished rendering. Excerpt from the getter:

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

Basically you may assume that the ViewData will be accessible from the beginning of the request inside you controller through the rendering of the view itself and it will be released after the page has finished rendering.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜