Search code examples
c#asp.netviewstate

Is ViewState Dictionary type declared as static?


Can I say that ViewState variable is equivalent to Dictionary type declared as static:

ViewState["clicks"] <=> static Object clicks = new Object();

Solution

  • No. ViewState is definitely not static. It is an instance property of Control (see Control.ViewState), and can change on every page and on every load of the same page.

    static variables in ASP.NET are quite dangerous if they contain personal data, since they are shared across all sessions, so you really don't want ViewState information to be static.