URL pass-through value/querystring
1, do not occupy server memory
2, the confidentiality of poor, the length of the transfer value is limited
Because of the poor confidentiality of the previous article, the limited value of the length can only be passed a string type value
The knowledge of this article is
Session
Assign value
String S=textbox1.text;
session["AA"]=s; AA is a value-only name that can also be used to accept the name of the value you are passing.
Response.deriect ("default.aspx");
Take value
label1.text=session["AA"].tostring ();
Let's say there's a student class pass value
Student s=new Student ();
S.name= "Zhang San";
S.sex=true;
session["AA"]=s;
Response.dedirect ("default.aspx");
Accept
Student s=session["AA"] as Student;
Label1.text=s.name;
Storage in server memory
Very good, very fast
Do not abuse, easy overflow
Life cycle: 20 minutes, every new request will refresh this time
Once the browser is closed (the same browser is not a page), then the connection to this session will be disconnected
Cookies
Identical to the session
Not the same place: Cookies are stored on the client's
Pass Value
String S=textbox1.text;
response.cookies["AA"].value=s;
Take value
if (request.cookies["AA"]!=null) assumes that no accepted value is set to the object null
{
String ss=request.cookies["AA"].value;
Label1.text=ss;
}
Identical to the session
Not the same place: Cookies are stored on the client's
Session is safe, but consumes server memory
Cookies, which do not consume server memory, exist on the client, but may be accessed
Persistent cookies
Assuming a period of 3 days
request.cookies["AA"]. Expires=datetime.now.adddays (3);
Withdrawal period is not held for a negative period
request.cookies["AA"]. Expires=datetime.now.adddays (-10);
Application
The pass value is the same as the session
application["AA"]=TEXTBOX1.TEXT;
Response.dedirect ("Default.aapx");
Take value
String s=application["AA"].tostring ();
Label1.text=s;
Storage on the server side, consuming server memory (as long as the server does not shut down or restarts)
Life cycle: Permanent (can be used as temporary database)
This is the object that everyone accesses.
Web-side session cookies application ViewState