Asp. NET provides a class System.Web.HttpContext, which is used to represent the context, which has a property items
The staging state is the use of the Httpcontext.items property to hold the data
The explanation for the Httpcontext.items property in MSDN is this: Gets the key value that can be used to organize and share data between IHttpModule and IHttpHandler during an HTTP request
The Httpcontext.items attribute can hold any type of data, regardless of what data is stored in this attribute, will be automatically purged after the request processing ends, this is the staging state, the data storage time is very short.
//For example://we have a page a.aspx, there is a button id:submit, click the button to turn the page b.aspx page Public voidSubmit_click (Object sender, EventArgs E) {SqlConnection myconnection=NewSqlConnection ("server= (local) netsdk;database=pubs; Trusted_connection=yes"); SqlDataAdapter mycommand=NewSqlDataAdapter ("SELECT * from Authors", MyConnection); DataSet DS=NewDataSet (); Mycommand.fill (DS,"Authors"); //put the data into the stagingcontext.items["MyData"] =ds; Server.Transfer (b.aspx); }//On the b.aspx page Public voidPage_Load (Object sender, EventArgs E) {if(!IsPostBack) { //Get Staging DataDataSet ds= (DataSet) context.items["MyData"]; //Other data Processes } }
Asp. NET state management four (staging state httpcontext.items)