1. Request-Gets the requested object
string s =request["key"];
2. Response-Response Request Object
Response.Redirect ("url"); Service End multiplicity orientation, jump on the current page.
Response.Write ("string"); Output this string to the top of the page, where you can put JS.
3. Session
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 connection to this session will be disconnected
Object type can be stored in session
(1), transfer value:
String S=textbox1.text;
session["AAA"]=S;
Response.Redirect ("url");
(2), Value:
label1.text= session["AAA"]. Tostring ();
(3), if error: Object reference is not set to an instance of an object.
Storage on the server side, occupying the memory of the servers. Once the browser is closed, the connection to this session will be disconnected
Handling: Judging when the value is taken
if (session["AAA"]!=null)
{
label1.text= session["AAA"]. Tostring ();
}
(4), if an object is passed:
Assignment: Users u= new users ();
U.username= "Lisi";
U.password= "123";
session["User"]=u;
Response.Redirect ("url");
Value: Users uu=session["user"] as Users;
Label1.text= UU. Username+uu. PassWord;
(5), the session after the end of the value can be directly released.
session["AAA"]=NULL;
4, the value of the Cookie can only wear string type.
Transmit value: string s =textbox1.text;
response.cookies["AA"]. Value=s;
response.cookies["AA"]. Expires=datetime.now.adddays (3); Set Cookies3 days to expire.
Response.Redirect ("url");
Value:string ss=request.cookies["AA"]. Value;
Label1.text=ss;
If an error occurs: The object reference is not set to an instance of the object.
To judge when a value is taken
if (request.cookies["AA"]!=null)
{
String ss=request.cookies["AA"]. Value;
Label1.text=ss;
}
Cookies are basically consistent with the session,
Not the same:cookies are stored on the client and can only be passed in string type.
Session is safe, but consumes server memory
Cookies, which do not consume server memory, exist on the client, but may be accessed
Assignment value:
response.cookies["AA"]. Value = s;
Value:
string ss = request.cookies["AA"]. Value;
5, Login and status hold.
In the Click event of the Login screen login button:
To take a value in the main interface:
Exit Login button for the main interface:
"2017-05-21" WebForm built-in objects: Session, Cookie, login and status hold