.net state management

a new instance of the web page class is created each time the page is posted to the server.

In traditional web programming , this would typically mean that all information associated with the page and the controls on the page would be lost with ech round trip.

 

To overcome this inherent limilation of traditional web programming, asp.net includes several options that help you preserve data on both a pre-page basis and an application-wide basis.

 

they are : view state; control state; hiddent fields; cookies; query strings; appliation stats; session; profile properties.

 

here are options which is client-based state:

1. view state:this is the default method that the page uses to preserve page and control property values between round trips.  when the page is processed, the current state of the page and controls is hashed into a string and saved in the page as a hidden field, a multiple hiddent fields. when the page is posted back to the server, the page parses the view-state string at page initialization and restores property information in the page. you can also use view state to store information of the page.

 

2. control state: use view state to store control-state data in order for a control to work properly. eg. you develop a customer control and there three tabs show different information, so the control needs to know which tab is selected between round trips. you can use view state to store this control state.

it's recommanded that the viewstate can be turned off at a page level by a developer.

 

3.Hidden Fields

a hidden field control which is renders as a standard html hiddent field. when a page is submitted to the server, the content of a hiddent fields is sent in the http from collection along with the values of other controls. do not store any sensitive information in hidden fields.

 

4.Cookies: is a small month of data this is stored either in a text file on the client file system or in-memory in the client browser session. it contains site-specific infomation that the server sends to the client along with the page output. Cookies can be temporary or persistent.

The cookies are saved on the client device, and when the browser requests a page, the client sends the information in the cookie along with the request information. The server can read the cookie and extract its value. A tyical use is to store a token indicating that the user has already been authenticated in your application.

 

5.query string : use url to send info from one page to another . eg. www.samplewebpage.com?key1= value1 & key2=value2.

 

Server-based state:

1. application state

application is global storage mechanism that is accessible from all pages in the web application. application state is stored in a key/value dictionary that is created during each request to a specific url.

 

2 session state

it is scoped to the current browser session. if different users are using your application, each user session will have a different session state.In addition, if a user leaves your application and then returns later, the second user session will have a diiferent session state from the first.

 

3profile properties

转载于:https://www.cnblogs.com/huangwj21/archive/2010/10/27/1862549.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值