When is ViewState session cleared ?

asp.net, c#, session-state, viewstate, visual-studio-2010

Solution

Viewstate lasts for as long as it's on the page - it's outputted with the HTML; check the source to your rendered page and you will see a load of text in a hidden field.

Something like:

<input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUJNTIyODQ4NzI.....

Once the page is gone, it's gone.

You can clear it by calling

ViewState.Clear()

Problem

I know SessionState is Cleared when the session dies - usually after 20min of inactivity. My question is when does ViewState session dies ? Or does it never dies ? Is there any way to clear it ?

Original source