title: ViewState and serialized object versioning
body: <p>We are using ASP.NET viewstate to store our own objects (ie, not just primitive types).  Each time we do a build, the build number is incremented.  The issue we are trying to work around is during a server update:</p>
  
  <ol>
  <li>User loads the page</li>
  <li>We deploy a new build of the web application</li>
  <li><p>User causes a postback on the same page, and an exception is thrown:</p>
  
  <ul>
  <li>HttpException: The state information is invalid for this page and might be corrupted.</li>
  <li>ViewStateException: Invalid viewstate.</li>
  <li>ArgumentException: The serialized data is invalid.</li>
  <li>FileLoadException: <em>Could not load file or assembly '[our assembly], Version=[our new version], Culture=neutral, PublicKeyToken=...' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference</em></li>
  </ul></li>
  </ol>
  
  <p>I understand why it's happening - the ViewState was serialized with the previous version of the class, and is then trying to deserialize with the new version and .NET serialization doesn't support that.</p>
  
  <p>We've considered creating a custom PageStatePersister and using JSON (and then encrypting it) to serialize/deserialize instead, since the data members are almost always compatible between builds.</p>
  
  <p>Any other ideas?</p>