10

How to decode the ASP.NET EventValidation and ViewState?

Jeff Sternal
  • 47,787
  • 8
  • 93
  • 120
Zanoni
  • 30,028
  • 13
  • 53
  • 73
  • For ViewState, see "How to decode viewstate": [http://stackoverflow.com/questions/22814/how-to-decode-viewstate/](http://stackoverflow.com/questions/22814/how-to-decode-viewstate/). – XP1 Mar 10 '13 at 18:21

5 Answers5

3

I answered a similar question recently, Getting values from viewstate using JQuery?.

Basically, by default ViewState is just Base64-encoded, so you can decode it as long as the administrator hasn't configured the site to encrypt it. Quoting from my previous answer:

If you are writing the control for your own consumption and you only need to read from ViewState, you could do so, but I wouldn't recommend it unless you find a well-debugged library to parse it for you. The format is a bit hairy (see ViewState: All You Wanted to Know for more details).

That link provides an extremely thorough and clear introduction to ViewState.

As for Event Validation, I'm unsure whether it's Base64-encoded or if it just looks like Base64 (I can't find a conclusive, authoritative reference). This Rexiology article might help though.

Community
  • 1
  • 1
Jeff Sternal
  • 47,787
  • 8
  • 93
  • 120
2

I'm not sure about EventValidation, but you can decode ViewState by using Fritz Onion's ViewState Decoder.

Bob Mc
  • 1,980
  • 1
  • 28
  • 38
  • Looks like Fritz pulled down the utility. A Google search pulls up this one first (http://ignatu.co.uk/ViewStateDecoder.aspx) but I cannot vouch for it. A shame really, Fritz' contribution was quite good. – Bob Mc Sep 22 '14 at 03:21
1

I needed to decode ViewStates recently and found this tool useful: View State decoder

syntagma
  • 23,346
  • 16
  • 78
  • 134
0

Create a simple windows app and use Convert.FromBase64(str) to decode ViewState data if it is not encrypted.

Note: GridView causes encryption.

Jérôme Verstrynge
  • 57,710
  • 92
  • 283
  • 453
0

You can use this link if use python.

Best way is use this link.

A small Python 3.5+ library for decoding ASP.NET viewstate.

First install that: pip install viewstate

>>> from viewstate import ViewState
>>> base64_encoded_viewstate = '/wEPBQVhYmNkZQ9nAgE='
>>> vs = ViewState(base64_encoded_viewstate)
>>> vs.decode()
('abcde', (True, 1))
henrry
  • 486
  • 6
  • 25