What does the __VIEWSTATE hold?

Alix Axel picture Alix Axel · Aug 29, 2009 · Viewed 27.2k times · Source

I'm sorry for maybe making such a basic question but in ASP.NET websites what does the __VIEWSTATE input field represent?

Also, is there any way to compute it's value (based on the values of other form fields)?

EDIT

I understand that __VIEWSTATE, as the name suggests, maintains the values of form field values in webpages however what I'm interested in knowing is how this state (the string) is generated. If I base64_decode any __VIEWSTATE string all I see is a bunch of cryptic HTML.

Is there any way to better understand what exactly is being encoded? I've searched on past questions and I've found some tools that can do this like this one, but unfortunately it doesn't seem to work.

The reason I'm asking this is because I've access to a web service API that gives me most of the values I need to work with. However I also need an additional field that is only available on the last stage of the form. I already contacted the web service provider but unfortunately and they're not going to update their API so soon. I was hoping I could prefill the form initial values using the web service data and then calculate the __VIEWSTATE to access the last field that shows up on the last stage of the form, it would make the whole process a lot faster.

Not sure if I made myself clear enough though...

Answer

russau picture russau · Aug 29, 2009

Paul Wilson has a very good article: ViewState: All You Wanted to Know

VIEWSTATE can be deserialized with the LosFormatter class.