title: How to determine which control causes the ViewState loading to fail?
body: <p>I am facing a Viewstate load issue with my page. </p>
  
  <p>Page has a login facility to log in admin and non-admin users. A strange behavior occurs when a non-admin user logs in to the page and clicks a checkbox which has autopostback enabled. (error details are given below)</p>
  
  <p>Later I found that, in the navigation panel on the left side (which hosts links) </p>
  
  <p>Sidebar is something as depicted below</p>
  
  <pre><code>Security
  ---------
  Link1
  Link2
  Link3
  
  Configuration
  ---------
  Link1
  Link2
  </code></pre>
  
  <p>If anything more than appears under the "Configuration" section, this exception gets thrown. The links are dynamically removed (from a full list) based on the user's privilege on Page_Load.</p>
  
  <p>How can I trace this kind of issues? I enabled all the exceptions in Visual Studio but it's not breaking to see which control causes this issue?</p>
  
  <blockquote>
    <p>Failed to load viewstate.  The control tree into which viewstate is
    being loaded must match the control tree that was used to save
    viewstate during the previous request.  For example, when adding
    controls dynamically, the controls added during a post-back must match
    the type and position of the controls added during the initial
    request.</p>
  </blockquote>
  
  <pre><code>[HttpException (0x80004005): Failed to load viewstate.  The control tree into which viewstate is being loaded must match the control tree that was used to save viewstate during the previous request.  For example, when adding controls dynamically, the controls added during a post-back must match the type and position of the controls added during the initial request.]
     System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +380
     System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +144
     System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +214
     System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +144
     System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +214
     System.Web.UI.Control.LoadChildViewStateByIndex(ArrayList childState) +144
     System.Web.UI.Control.LoadViewStateRecursive(Object savedState) +214
     System.Web.UI.Page.LoadAllState() +464
     System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1729
  </code></pre>