Getting "Failed to load viewstate" from a page refresh
<p>I have a asp.net page that is dynamically created according to an XML description I have made.</p>

<p>The following error is occurring (sometimes)</p>

<p><strong>"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."</strong></p>

<p>It seems to happen consistently in production but less often when run in debug from visual studio.</p>

<p>Here is the page.</p>

<pre><code>&lt;form id="form1" runat="server"&gt;

&lt;asp:ScriptManager ID="ScriptManager1" runat="server" /&gt;
&lt;asp:Timer ID="ScreenRotateTimer" runat="server" ontick="ScreenRotateTimer_Tick" Interval="3600000"&gt;&lt;/asp:Timer&gt;
&lt;asp:Timer ID="RefreshTimer" runat="server" Interval="3600000" ontick="RefreshTimer_Tick" /&gt;

&lt;asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"&gt;
    &lt;ContentTemplate&gt;
            &lt;asp:PlaceHolder ID="PlaceholderControls" runat="server"&gt;
                &lt;h1&gt;ERROR&lt;/h1&gt;
                &lt;h3&gt;An invalid view was specified or no view was passed to the URL Query String&lt;/h3&gt;
            &lt;/asp:PlaceHolder&gt;
    &lt;/ContentTemplate&gt;
    &lt;Triggers&gt;
        &lt;asp:AsyncPostBackTrigger ControlID="RefreshTimer" EventName="Tick" /&gt;
    &lt;/Triggers&gt;
&lt;/asp:UpdatePanel&gt;

&lt;/form&gt;
</code></pre>

<p>The following method will parse an xml file from the file system and place the results into <code>PlaceholderControls</code></p>

<pre><code>    protected void Page_Init(object sender, EventArgs e) {
        parseXmlScreen();
    }
</code></pre>

<p>At a regular interval the entire page might be refreshed (say 30 seconds), The Xml file contains many monitor definitions, only one can be seen at a time.  This is controlled by the <strong>static variable currentMonitorIndex</strong>.</p>

<pre><code>    protected void ScreenRotateTimer_Tick(object sender, EventArgs e)
    {
        //Move to the next monitor in the screen
        if (monitorCount == currentMonitorIndex+1)
            currentMonitorIndex = 0;
        else
            currentMonitorIndex++;

        Response.Redirect(Request.RawUrl);
    }
</code></pre>
