views:

19

answers:

1

The reason for this is that there is a specific issue where exclamation marks followed by whitespace are placed in the VIEWSTATE by some random company routers/server/something.

After removing these, the VIEWSTATE is fine and can be deserialised (as confirmed by View State Decoder 2 which is a pretty cool program).

So, what I want to do is to

  1. catch the error that occurs
  2. check the VIEWSTATE for this issue
  3. modify the VIEWSTATE (remove !'s)
  4. try to parse the VIEWSTATE again

I am working on trying to override the LoadPageStateFromPersistenceMedium in the System.Web.UI.Page and work magic from there. Still working on it...

A: 

Try these methods: SavePageStateToPersistenceMedium and LoadPageStateFromPersistenceMedium that you can override in your page. There you can intercept the VIEWSTATE that gets rendered in the page or comes from the hidden field in the page.

Cheers!

Update - I once used this to compress the VIEWSTATE so maybe you can change it to suit your needs. Here is how the compressed value gets loaded from the page (in your case the one with whitespace) and the decompressed value is deserialized as the actual VIEWSTATE:

    protected override object LoadPageStateFromPersistenceMedium()
    {
        string vsString = Request.Form["__COMPRESSEDVIEWSTATE"];
        byte[] bytes = Convert.FromBase64String(vsString);
        bytes = Compression.Decompress(bytes);
        return formatter.Deserialize(Convert.ToBase64String(bytes));
    }
Padel