28 June 2006

[ASP.NET 1.x] Storing ViewState in Session State

Help.Net wants to know if storing the ASP.NET ViewState in memory is scalable...

OF COURSE IT'S NOT SCALABLE!

It's really unfortunate that MSDN Magazine published this method. It's an insanely bad idea to store ViewState contents in memory. In-memory Session objects are subject to timeout and memory pressures. This means that you cannot rely on in-memory Session as a container for critical data. It's also why .NET 2.0 provides two other providers for Session storage, file and SQL. If you're now thinking it would be really smart to store ViewState in Session and Session in SQL. Well then you haven't thought things through. This method would result in the data being serialized/deserialized twice. Not very smart.

If your ViewState is so freaking huge that you are looking for better places to store it then your problem is poor application design. If you really cannot trim the size of your ViewState then write a filesystem or SQL provider for ViewState storage. That way at least your still only serializing the data once.

0 Comments:

Post a Comment

Links to this post:

Create a Link

<< Home