This is a mirror of official site: http://jasper-net.blogspot.com/

How to store ViewState on the server - the *RIGHT* way!

| Thursday, March 25, 2010
Many have tried to implement serialization of ViewState on the server, and many have failed, which is quite easy to understand considering even Microsoft's reference documentation on this subject is in fact *WRONG*...!

Of all the samples you find when you search for "storing ViewState on server in ASP.NET", virtually all the top ones are *WRONG*. Even Microsoft's reference documentation on this is wrong! Take a look at Microsoft's documentation for PageStatePersister for instance and try to find the bug. No wonder people are having a hard time implementing this feature. In fact if you do it the way described at Microsoft, and your solution depends upon upon ControlState, you will fail miserably...!

I have historically argued against storing ViewState on the server, mostly because I've seen so many wrong solutions, like for instance some developers are storing their ViewState in the Session object. This is a *terrible* thing to do and should be never be done! And yes, I know Microsoft even have a "shortcut" for doing it, but you can't justify terrible code just because Microsoft gave you the tools to do it! Bad code is bad code, even when it's Microsoft code! When you store your ViewState in your Session object on the server, you're basically turning the most scalable and beautiful platform ever created [the web] and turning it into an Outlook client. Needless to say, scalability goes out the window, and a system that would normally be able to handle thousands of concurrent users, will break down if more than 5 people are using it simultaneously! So whenever people have asked me how to store the ViewState on the server, I've basically answered; *DON'T*...!

Read more: ra-ajax.org

Posted via email from jasper22's posterous

0 comments: