Several database objects saved in asp.net

Source: Internet
Author: User

A series of beginning and end actions. Data Privacy, session termination, resource release, and memory saving for accessors

Easy to lose and difficult to determine the timeout

Session ["key name"] = Value

Cookie is a small amount of text data stored on the client by the website.

Advantage: 8 K of data can be stored theoretically, and the validity period can be customized, which does not occupy disk space on the server and provides better stability.

Disadvantages: easy to lose and poor security

C # code for writing data to cookies:

Response. Cookies ["userlgin"]. value = "tom ";

C # code for reading client Cookie data:

String uName = Request. Cookie ["userName"];

Application

Cache

Xml

File

Database

VieWState

 

// Use the ViewState object to save the value. The valid range of this object is that the current page can be accessed. It is stored on the client. Send back each time
// ViewState is the StateBag class. The data types that can be stored include int bool string or array and its basic data types, and arraylist, hashtable,
// Or a type with a type converter that can be serialized
Public string Text
{
Get
{
If (ViewState ["value"] = null)
{
Return String. Empty;
}
Return (string) ViewState ["value"];
}
Set
{
ViewState ["value"] = value;
}
}

Aspnetdb database profile personalized configuration member qualification and role management

 

Request. Tranfer ()

 

Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. WebControls;
Using System. Web. Security;
Using BLL;
Using System. Data;

Public partial class User_Question_Default: System. Web. UI. Page
{
Public int num = 9;
Private string name = "sa ";

Public string Name
{
Get {return name ;}
Set {name = value ;}
}
Private string email = "@ 263 ";

Public string Email
{
Get {return email ;}
Set {email = value ;}
}
Protected void Page_Load (object sender, EventArgs e)
{

}


Protected void button#click (object sender, EventArgs e)
{
Context. Server. Transfer ("Default2.aspx", true );
}
}

 

Target page:

 

Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Web;
Using System. Web. UI;
Using System. Web. UI. WebControls;

Public partial class User_Question_Default2: System. Web. UI. Page
{
Protected void Page_Load (object sender, EventArgs e)
{
User_Question_Default ud = (User_Question_Default) Context. Handler; // an error is reported and the running is not affected,

Response. Write (ud. Name. ToString ());
// Response. Write (Request. Form ["TextBox1"]. ToString (); // get a class object, which can be freely operated
}
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.