Copy Code code as follows: 
 
 
  
 
 
public class Xvpage:page 
 
{ 
 
static private DirectoryInfo _dir; 
 
Private DirectoryInfo Dir 
 
{ 
 
Get 
 
{ 
 
if (_dir = null) 
 
{ 
 
_dir = new DirectoryInfo (Path.Combine (AppDomain.CurrentDomain.BaseDirectory, "App_Data")); 
 
if (!_dir.exists) 
 
_dir.create (); 
 
_dir = new DirectoryInfo (Path.Combine (_dir.fullname, "ViewState")); 
 
if (!_dir.exists) 
 
_dir.create (); 
 
} 
 
return _dir; 
 
} 
 
} 
 
protected override Object LoadPageStateFromPersistenceMedium () 
 
{ 
 
PageStatePersister PS = this. PageStatePersister; 
 
Ps. Load (); 
 
if (Ps. ControlState!= null) 
 
Ps. ControlState = Antiserialization ((string) ps. ControlState); 
 
if (Ps. ViewState!= null) 
 
Ps. ViewState = Antiserialization ((string) ps. ViewState); 
 
return new Pair (PS. ControlState, PS. ViewState); 
 
} 
 
protected override void Savepagestatetopersistencemedium (object state) 
 
{ 
 
PageStatePersister PS = this. PageStatePersister; 
 
If (state is Pair) 
 
{ 
 
Pair Pair = (Pair) state; 
 
Ps. ControlState = pair. A; 
 
Ps. ViewState = pair. Second; 
 
} 
 
Else 
 
{ 
 
Ps. ViewState = State; 
 
} 
 
if (Ps. ControlState!= null) 
 
Ps. ControlState = Antiserialization (PS. ControlState); 
 
if (Ps. ViewState!= null) 
 
Ps. ViewState = Antiserialization (PS. ViewState); 
 
Ps. Save (); 
 
} 
 
Private Object Antiserialization (String Stateid) 
 
{ 
 
String statestr = (string) Cache[stateid]; 
 
string file = Path.Combine (Dir.fullname, Stateid); 
 
if (statestr = null) 
 
Statestr = File.readalltext (File); 
 
Else 
 
Cache.remove (Stateid); 
 
return new ObjectStateFormatter (). Deserialize (STATESTR); 
 
} 
 
private string Antiserialization (Object obj) 
 
{ 
 
String value = new ObjectStateFormatter (). Serialize (obj); 
 
String Stateid = (DateTime.Now.Ticks + (long) value. GetHashCode ()). ToString (); Generate a discrete ID number 
 
File.writealltext (Path.Combine (Dir.fullname, Stateid), value); 
 
Cache.Insert (Stateid, value); 
 
return Stateid; 
 
} 
 
protected override void OnUnload (EventArgs e) 
 
{ 
 
Base. OnUnload (e); 
 
DateTime dt = DateTime.Now.AddMinutes (-20); 
 
foreach (FileInfo fl in dir.getfiles ()) 
 
if (fl. LastAccessTime < DT) 
 
Try 
 
{ 
 
Fl. Delete (); 
 
} 
 
Catch 
 
{ 
 
} 
 
} 
 
} 
 
 
 
 
You just need to inherit xvpage in the background of the page. 
public partial class Index_content:xvpage