Asp. NET provides a class System.Web.HttpContext that is used to represent the context, which has a property items
Staging state is the use of the Httpcontext.items attribute to store data
The Httpcontext.items attribute in MSDN explains this: Gets the key values that can be used to organize and share data between IHttpModule and IHttpHandler during the HTTP request process
The Httpcontext.items property can hold any type of data, regardless of what data is stored in this property, will be automatically cleared at the end of the request processing, 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 to b.aspx page public
void Submit_click (Object sender, EventArgs E)
{
SqlConnection myconnection = new SqlConnection ("server= (local) netsdk;database=pubs;" Trusted_connection=yes ");
SqlDataAdapter mycommand = new SqlDataAdapter ("select * from Authors", myconnection);
DataSet ds = new DataSet ();
Mycommand.fill (ds, "Authors");
Put the data into the temporary storage
context.items["MyData"] =ds;
Server.Transfer (b.aspx);
}
Public
void Page_Load (Object sender, EventArgs E)
{
if (!) in b.aspx page. IsPostBack)
{
//Obtain staging Data
DataSet ds= (DataSet) context.items["MyData"];
Additional data Procedure
}
}
We also saw the use of this feature in Ibuyspyportal:
The query string contains the Tabindedx and TabID parameters of the tab that is being requested. This information is used throughout the process of processing the request to filter the data to be displayed to the user.
http://www.ibuyspyportal.com/DesktopDefault.aspx?tabindex=1&tabid=2
To use a query string value, you need to first make sure that it is a valid value, and if not, do some error handling. It's not a bunch of code, but do you really want to copy it in every page and component that uses that value? Of course not! In the Portal example, even more is involved, because once we know tabid, we can preload other information.