This is a migrated thread and some comments may be shown as answers.

Odd viewstate error

5 Answers 126 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
Thomas
Top achievements
Rank 1
Thomas asked on 03 Apr 2008, 01:49 AM
I'm running into an odd viewstate error. The official error I'm getting is "The state information is invalid for this page and might be corrupted."

Here's how to reproduce. Create two pages. Mine both used a master page but I don't think that matters in this case. The first page simply needs a link to the second page. On the second page, add a RadGrid and RadAjaxManager like so:

    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" 
        GridLines="Horizontal" 
        OnNeedDataSource="RadGrid1_NeedDataSource" 
        AllowAutomaticDeletes="True" AllowAutomaticInserts="True" AllowAutomaticUpdates="True" > 
        <MasterTableView DataKeyNames="Key" EditMode="InPlace" CommandItemDisplay="Top"
            <Columns> 
                <telerik:GridEditCommandColumn> 
                </telerik:GridEditCommandColumn> 
                 
                <telerik:GridBoundColumn DataField="Name"
                </telerik:GridBoundColumn> 
            </Columns> 
        </MasterTableView> 
    </telerik:RadGrid> 
     
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="RadGrid1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="GridLoadingPanel" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
     
    <telerik:RadAjaxLoadingPanel ID="GridLoadingPanel" runat="server" Transparency="30"
        <img alt="Loading..." 
            style="margin-top: 100px; border-width: 0px;"  
            src='<%= RadAjaxLoadingPanel.GetWebResourceUrl(Page, "Telerik.Web.UI.Skins.Default.Ajax.loading.gif") %>' /> 
    </telerik:RadAjaxLoadingPanel> 

In my case, the grid's data source in the NeedDataSource event is a custom collection of "Foo" items which look like:

    public class Foo 
    { 
        #region public string Key 
        private string _key; 
        public string Key 
        { 
            get { return _key; } 
            set { _key = value; } 
        } 
        #endregion 
        #region public string Name 
        private string _name; 
        public string Name 
        { 
            get { return _name; } 
            set { _name = value; } 
        } 
        #endregion 
    } 
 


To reproduce the problem do the following:
1. Go to your first page and use your link to navigate to the second page.
2. Click the "Add" button on the grid.
3. Hit the (evil) Back button on your browser.
4. Hit the (more evil) Forward button on your browser.
5. Click the "Add" button again.

If I disable ViewState MAC checking, I get an Invalid ViewState error.

Is there a fix for this other than user education?

5 Answers, 1 is accepted

Sort by
0
Steve
Telerik team
answered on 03 Apr 2008, 10:15 AM
Hi Thomas,

Is this error by any chance caused only on Firefox? If this is the case can you add the following to the Page_Load of the offending page:

protected void Page_Load(object sender, EventArgs e)
{
   if (Request.Browser.MSDomVersion.Major == 0) // Non IE Browser?)
   {
       Response.Cache.SetNoStore(); // No client side cashing for non IE browsers
   }
}

If this is happening on IE as well, please make sure that the GridEditCommandColumn has ButtonType different than ImageButton.
If the above does not help, please elaborate how do you redirect to the other page - do you use Response.Redirect? What type of control makes the redirect? Any additional information would be highly appreciated.

Sincerely yours,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Thomas
Top achievements
Rank 1
answered on 03 Apr 2008, 08:12 PM
I have confirmed that the problem only occurs in FF. However, isn't disabling all client side caching a bit draconian? Isn't that like putting out a match with a fire engine hose?

(Btw, the redirect can be a simple href tag).
0
Steve
Telerik team
answered on 04 Apr 2008, 01:10 PM
Hello Thomas,

We've found this solution somewhere in mozillazine if I recall correctly, where someone else has encountered this problem in other scenarios. There was a discussion about that but unfortunately there is no other "workaround" for the time being as this is entirely mozilla specific behavior that we do not have control over.
Can you share what is bothering you, when having this setting enabled?

Kind regards,
Steve
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
DonKitchen
Top achievements
Rank 1
answered on 28 May 2009, 05:48 PM
Steve (or other Telerik staff),

I'm curious why you suggest this for IE:

If this is happening on IE as well, please make sure that the GridEditCommandColumn has ButtonType different than ImageButton.

0
Sebastian
Telerik team
answered on 29 May 2009, 08:09 AM
Hello Don,

This is rather an old thread and most probably there was some kind of issue with the Prometheus (Beta) version of RadControls for ASP.NET AJAX in this case. I suggest you migrate to the latest release 2009.1.527 of RadControls to see whether the problem disappears.

You may also test the same case by removing the RadAjaxManager from the page and using MS UpdatePanel to ajaxify the grid or plain postbacks to compare the results. This can shed some additional light on whether the issue is related to the ASP.NET AJAX framework or particularly to some of our controls.

Kind regards,
Sebastian
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
Tags
Ajax
Asked by
Thomas
Top achievements
Rank 1
Answers by
Steve
Telerik team
Thomas
Top achievements
Rank 1
DonKitchen
Top achievements
Rank 1
Sebastian
Telerik team
Share this question
or