views:

6076

answers:

11

I need to see the contents of the viewstate of an asp.net page. I looked for a viewstate decoder, found Fridz Onion's ViewState Decoder but it asks for the url of a page to get its viewstate. Since my viewstate is formed after a postback and comes as a result of an operation in an update panel, I cannot provide a url. I need to copy & paste the viewstate string and see what's inside. Is there a tool or a website exist that can help viewing the contents of viewstate?

+6  A: 

Use Fiddler and grab the view state in the response and paste it into the bottom left text box then decode.

Darren Kopp
If you don't want to install Fiddler, you can also use the HttpFox add-on for Firefox: https://addons.mozilla.org/en-US/firefox/addon/6647
Chris Shouts
A: 

Isn't it just a base 64 encoded version of the serialized data?

mercutio
+1  A: 

Darren's suggestion worked but apparantly decoder did not like my viewstate string. It gives a "the serialized data is invalid" message.

Serhat Özgel
+1  A: 

As another person just mentioned, it's a base64 encoded string. In the past, I've used this website to decode it:

http://www.motobit.com/util/base64-decoder-encoder.asp

Josh Hinman
A: 

You can ignore the URL field and simply paste the viewstate into the Viewstate string box.

It does look like you have an old version; the serialisation methods changed in ASP.NET 2.0, so grab the 2.0 version

blowdart
A: 

@blowdart:

I already have that version.

I also tried with the site joshhinman has suggested but what i got was some meaningless chars. May be there is a problem with my viewstate string. Is it possible (since it is auto-generated, i do not think it is broken)?

Serhat Özgel
A: 

buyutec, stupid question: are you encrypting your viewstate? If you are, you (obviously) won't be able to decode it. I imagine you probably already thought of this, but it shouldn't go unmentioned.

Josh Hinman
+1  A: 

@joshhinman

(: No, I do not encrypt it.

Serhat Özgel
A: 

Normally, ViewState should be decryptable if you have the machine-key, right? After all, ASP.net needs to decrypt it, and that is certainly not a black box.

Michael Stum
A: 

What happens if ASP.NET cannot read it?

I have a repeater on the page which loses its data. When the page posts back, i cannot see its items through Items property. That's why I am trying to read the viewstate and check for a problem. May a broken viewstate be the reason?

Serhat Özgel
A: 

@Michael

of course, you are correct. I meant that if it's encrypted, you won't be able to decode it easily

Josh Hinman