Created
February 2, 2010 12:56
-
-
Save mpj/292641 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected override void SavePageStateToPersistenceMedium(object viewState) | |
{ | |
if (Page.ToString() == "ASP.default_aspx") | |
{ | |
string str = "VIEWSTATE_" + Request.UserHostAddress + "_" + DateTime.Now.Ticks.ToString(); | |
Session[str] = viewState; // session works in web garden | |
//Cache.Add(str, viewState, null, DateTime.Now.AddMinutes(Session.Timeout), TimeSpan.Zero, | |
//CacheItemPriority.Default, null); | |
ClientScript.RegisterHiddenField("__VIEWSTATE_KEY", str); | |
ClientScript.RegisterHiddenField("__VIEWSTATE", ""); | |
} | |
else | |
{ | |
base.SavePageStateToPersistenceMedium(viewState); | |
} | |
} | |
protected override object LoadPageStateFromPersistenceMedium() | |
{ | |
if (Page.ToString() == "ASP.default_aspx") | |
{ | |
string str = Request.Form["__VIEWSTATE_KEY"]; | |
if (!str.StartsWith("VIEWSTATE_")) | |
{ | |
throw new Exception("Invalid viewstate key:" + str); | |
} | |
return Session[str]; | |
} | |
else | |
{ | |
return base.LoadPageStateFromPersistenceMedium(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment