问题
What is the best way to save view state on server?
Is it a good idea to use a WCF service to save the view state on the server?
回答1:
Are we talking about ASP.NET view state? Why do you need WCF to store view state on the server? ASP.NET provides its own methods to store view state on the server:
You can override
SavePageStateToPersistenceMediumandLoadPageStateFromPersistenceMediumon yourPage.You can override
PageStatePersisterproperty of yourPage(or in customPageAdapter). This property by default returnsHiddenFieldPageStatePersisterbut you can change it toSessionPageStatePersisteror implement customPageStatePersister. Here you can read about PageStatePersisters.
回答2:
There's a project on CodeProject that you should look at called Efficient Server-Side View State Persistence. This meets the following criteria:
- The View State needs to be persisted on the server.
- The View State persistence mechanism needs to be identified by a specific user session.
- The persisted View State artifact must not be allowed to remain forever.
- The persisted View State should be able to be enabled and disabled on a page by page bases.
- Different persistence mechanisms should be able to be used.
- Page development and structure should not be modified.
来源:https://stackoverflow.com/questions/4645696/saving-viewstate-on-server