views:

28

answers:

1
+3  Q: 

Caching viewstate?

ViewState Chaching

This is a great idea, but it's implemented for sharepoint .Wonder if there is a solution for regular asp.net pages, which does the same, caches viewstates.

+4  A: 

It's actually quite simple! You just need to override these two methods on your page:

SavePageStateToPersistentMedium()

LoadPageStateFromPersistenceMedium()

In there, you can get the ViewState object tree, serialize it however you want and store it wherever you want (Session, SQL, etc), and instead of returning the entire serialized blob to the browser, just return a unique ID you can use to look it up again next time around.

The idea is covered in painstaking detail here: http://msdn.microsoft.com/en-us/library/ms972976.aspx

Rex M