PageContext over ViewState
Our application uses ViewState for storing page level variables. We are planning to migrat开发者_如何学JAVAe the same to use PageContext. Are there any drawbacks of Page Context over ViewState or vice versa.
Context objects can persist across pages. Only on a Server.Transfer will Context.Items collection persist. A Response.Redirect is a postback and Context objects do not survive postbacks... But guess what does survive postbacks Postbacks Server.Transfer Context.Items No Yes View State Yes No
So a common combo technique I've seen is: Starting in Page A storing an object in Context, navigating to a another Page B (via Server.Transfer) and assuming that Page B may involve some postback at some point, reading the Context object into ViewState.
Can refer this link http://dotnetjeet.com/post/ContextItems-vs-ViewState.aspx
精彩评论