Hi Tim,
View State can be customized to be stored in a Session or Cache object. It
is done by overriding the 'SavePageStateToPersistenceMedium' and
'LoadPageStateFromPersistenceMedium' methods. (see code snippet below)
protected override void SavePageStateToPersistenceMedium(Object viewState)
{
string _vskey;
_vskey = "VIEWSTATE_" + base.Session.SessionID + "_" + Request.RawUrl +
"_" + System.DateTime.Now.Ticks.ToString();
Cache.Add(_vskey, viewState, null,
System.DateTime.Now.AddMinutes(Session.Timeout), Cache.NoSlidingExpiration,
CacheItemPriority.Default, null);
RegisterHiddenField("_VIEWSTATE_KEY", _vskey);
}
protected override object LoadPageStateFromPersistenceMedium()
{
string _vskey = Request.Form["_VIEWSTATE_KEY"];
if (_vskey == null)
{
return null;
}
else
{
return Cache[_vskey];
}
}
Advantages: If the ViewState is large, it increases the page size
considerably and results in an increase in response time (page load time).
Saving the ViewState to a session/cache can result in an improved response
time (page size is reduced considerably). On the other hand, it can consume
server resources (which can be handled by improving the hardware).
Regards,
Augustin
AAOMTim said:
I have a large ViewState and I've heard I can save the ViewState in a sesison
object. What are the advantages of doing so and how do I do it? I've been
told that I am gettign DNS timeouts because of the ViewState being too large.
I'm trying to avoid writing manual paging routines for now.