public override void Load() { _hiddenFiledPagePersister.Load(); string viewStateStr = _hiddenFiledPagePersister.ViewState as string; // Page.Request.Form[STATE_KEY]; trace.WriteTrace(TraceSeverity.InformationEvent, TraceCategory.Content, "View state: " + viewStateStr); if (viewStateStr != null && viewStateStr.StartsWith(CacheKeyPrefix)) // state not inline check the cached state key { string state = LoadState(viewStateStr); if (state == null) { trace.WriteTrace(TraceSeverity.CriticalEvent, TraceCategory.Content, "View state lost. Probably cached item expired."); } else { try { Pair data = (Pair)StateFormatter.Deserialize(state); ViewState = data.First; ControlState = data.Second; } catch { trace.WriteTrace(TraceSeverity.Exception, TraceCategory.Content, String.Format("Could not deserialize view state. View state is invalid.")); } } } else { ViewState = _hiddenFiledPagePersister.ViewState; ControlState = _hiddenFiledPagePersister.ControlState; } }
// // Summary: // Deserializes and loads persisted state from the repository when // a System.Web.UI.Page object initializes its control hierarchy. // // Exceptions: // T:System.Web.HttpException: // The System.Web.UI.SessionPageStatePersister.Load method could not successfully // deserialize the state contained in the request to the Web server. public override void Load() { string viewStateKey; if (UseDefaultViewStateHiddenField) { // Get key from __VIEWSTATE hidden field HiddenFieldPageStatePersister _hiddenFiledPagePersister = new HiddenFieldPageStatePersister(Page); _hiddenFiledPagePersister.Load(); viewStateKey = _hiddenFiledPagePersister.ViewState as string; } else { // Get key from custom hidden field //string viewStateKey = Page.Request.Params[ViewStateHiddenFieldName] as string; viewStateKey = Page.Request.Form[ViewStateHiddenFieldName] as string; } if (!string.IsNullOrEmpty(viewStateKey)) { ViewStateInfo info = (ViewStateInfo)Repository.GetViewState(viewStateKey); IStateFormatter formatter = this.StateFormatter; Pair statePair = (Pair)formatter.Deserialize((string)info.Value); ViewState = statePair.First; ControlState = statePair.Second; // Remove from repository after serve } }