Vishwajeet
Vishwajeet

Reputation: 1683

Save page view state on Server, and not allow it to go back browser

Is it possible that we not allow the view state of a page to not shows on browser (hidden field). Instead of it it saves somewhere on server side

Upvotes: 0

Views: 809

Answers (1)

Aristos
Aristos

Reputation: 66641

Yes you can save it on server on a database

You overwrite this two function of the page

protected virtual void SavePageStateToPersistenceMedium (object viewState);
protected virtual object LoadPageStateFromPersistenceMedium();

and on save you add to the page a unique id and you save the viewstate the database, and connect it with this unique ID. You need to clear it time to time to remove the non used viewstate data

here is a full working example with the source code: http://www.codeproject.com/Articles/8001/ViewState-Provider-an-implementation-using-Provide

For me the better is to reduce the viewstate that you use on controls, and compress it. Usually the viewstate after correct using of it is too small. Also remember that the viewstate is used on post back, on page with out the use of post back can be even none.

How I can deactivate ViewState without Control problems

Upvotes: 1

Related Questions