Is ViewState Dictionary type declared as static?

109 views Asked by At

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

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

There are 2 answers

0
Patrick Hofman On BEST ANSWER

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.

0
dcastro On

You mean the Control.ViewState property? It's not static, and it's a StateBag.

StateBag implements the non-generic IDictionary interface