ViewState believe everyone will use, but viewstate in the end is what, and how many people know?
StateBag class that's not much to say.
In asp.net 2.0, there are three places to use StateBag.
1 Control._viewstate This is the viewState that everybody uses
2 Webcontrol.attrstate This is a store attribute.
3 Style.statebag is a store style.
.......
When saveallstate in page life cycle
Need mister into a Piar class, in calling this. Savepagestatetopersistencemedium (PAIR1), serializing it
Note: asp.net2.0 only implements Hiddenfieldpagestatepersister, and users can provide other forms of mechanism from overrides, or using ControlAdapter
Hiddenfieldpagestatepersister.save when Pair1 is serialized
When serialized,. NET provides three ways
1 Using a key
2. Using Mac
3 Do not use
Serialization first
This. Serialize (OutputStream, stategraph);
Outputstream.setlength (outputstream.position);
byte[] buf = Outputstream.getbuffer ();
int length = (int) outputstream.length;
Determines whether the current Page.requiresviewstateencryptioninternal property return value requires encryption
If Page.registerrequiresviewstateencryption is not invoked, the default is False
If the interface is set to RegisterRequiresViewStateEncryption and enableViewStateMac, encryption takes precedence over the Mac
if (this._page!= null) && this._page. requiresviewstateencryptioninternal)//encryption
{
BUF = Machinekeysection.encryptordecryptdata (True, buf, this. Getmackeymodifier (), 0, length);
Length = buf. Length;
}
else if ((this._page!= null) && this._page. enableViewStateMac) | | (this._mackeybytes!= null)) Setting can use Mac
{
BUF = Machinekeysection.getencodeddata (buf, this. Getmackeymodifier (), 0, ref length);
}
Text = convert.tobase64string (buf, 0, length); Null of either
Speaking of this, a lot of people want to ask what is in the Pair1, I drew a picture, detailed description of the