Thursday 15 April 2010

asp.net - Problem with LoadViewState after F5 page refresh - Failed to load viewstate -


I'm having trouble with a veststate and F5 page refresh in my ASP.NET application.

Once you navigate to and I immediately hit F5 to a page, I get the following error:

  System.InvalidCastException "Type 'System.Web to type. unable to cast object of UI.Triplet '' System.Web.UI.Pair '. " 

displayed on this page is the following exceptions:

  HttpException (0x80004005): Viewstate failed to load control tree in which the viewstation being loaded should match the control tree whose sub Yoga was done to save the viewstation during the previous request. For example, when control dynamically adding, type added during back control and match more control of the situation during the initial request.] System.Web.UI.Control.LoadViewStateRecursive (object savedState) 310 System. Web .UI.Control.LoadChildViewStateByIndex (ArrayList childState) 136 System.Web.UI.Control.LoadViewStateRecursive (object savedState) 224 System.Web.UI.Control.LoadChildViewStateByIndex (ArrayList childState) 136 System.Web.UI.Control. LoadViewStateRecursive (Object Reserved Static) +224 System Web. UI. Control LoadChild ViewStateByIndex (ArrayList child state) +136 system. Web. UI. Control Load vevastet reverse (object saved) +224 system Web. UI. Control. Landshield ViewStateByIndex (ArrayList childState) 136 System.Web.UI.Control.LoadViewStateRecursive (Object savedState) 224 System.Web.UI.Control.LoadChildViewStateByIndex (ArrayList childState) 136 System.Web.UI.Control.LoadViewStateRecursive (object savedState) 224 System .Web is .UI.Page.LoadAllState () is +439 S ystem.Web.UI.Page.ProcessRequestMain (Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) 1092  

the point at which it failed, override a custom label control in LoadViewState method when it tells parents LoadViewState

  System.Web.UI.WebControls.Label.LoadViewState (ByVal savedState in kind)  

savedState object one page Appears to re different control (a drop-down list), which is required by System.UI.Pair object label control Sistmkaibikuai. Triplet, instead.

If I really use the same thing in a single application, then a separate page, the page load is fine after the postback F5 postback. Two web pages are successors from the same base category and use the same custom control. There is no dynamically added control in the page causing the problem.

After debugging this process, it seems that the LoadViewState event is not being removed after the F5 postback to control the page that successfully loads. SaveViewState has been removed in both cases.

Any ideas why the LoadViewState event will be removed for one page, but not the other? I'm quite new to ASP.Net and I'm still seeing my head how the viewstate works.

It is difficult to say a lot without seeing your code, however, there are some things that can help: / P>

  1. You might want to see the HTTP Exchange during failing to use Web debugger like Frederor; There is a good chance that the answer will get out on you.
  2. Remember that F5 issues the final request again. If you are navigating from one page to another, there should not be any viewstate, unless you are posting a cross-page.
  3. If the viewstate is not being sent with the request, then the nature of the failure is the way in which you are encoding it, what is there with anything?
  4. The LoadViewestate () should be called only when the incoming request contains the viewstate that should be loaded in the respective control.
  5. To continue the state of control in SaveViewState () in the hidden area of ​​the page, each page is requested for a request, so that it is available during a postback.

No comments:

Post a Comment