Sunday 17 February 2013

State Management in Asp.Net



When a request sent to web server, then a connection will be established and response will be send to browser. Then connection will be closed and webpage variables i.e...data will be erased.
This nature of the web is called as stateless nature of the web. Since HTTP is stateless protocol.
This stateless nature is an advantage, this will allow web server to maintain less number of connections. So this will improve performance of web server.
About State Management
STATE MANAGEMENT is a concept of web server maintaining data of clients without maintaining connectivity. This can be implemented through various techniques.These are...
  1. QUERY STRING
  2. CONTEXT OBJECT
  3. COOKIES
  4. SESSION MEMORY
  5. APPLICATION
  6. CACHE
  7. PAGE SUBMISSION
  8. VIEW STATE
Query String
This is required to maintain state of user from one page to another page, when the redirection is performed using Response.Redirect method.
Context Object
The context object will maintain state of user from one page to another page when the redirection is performed using Server.Transfer method.

Cookies
Cookie is a small amount of memory used by web server within client system.
The purpose of cookies is to maintain personal information of client within client system to reduce burden on server. This is called client-side state management.
The personal information can be login parameters, number of visits, etc.
There are two types of cookies.
1. In Memory Cookie.
  • The cookie placed within browser process memory is called in memory cookie. This is temporary cookie.
2. Persistent Cookie.
  • The cookie placed on permanent memory or hard disk memory with a particular life time is called persistent cookie.
    This cookie will be acceptable to all the browsers within client system. The cookie will be stored under network login folder of client.
Additional Information:
  1. A cookie does not provide security..
  2. A cookie can carry a maximum of 4 KB of data
  3. A browser supports maximum of 20 cookies towards a website.
  4. A browser supports maximum of 300 cookies towards different websites.
  5. Cookie requires path to maintain uniqueness.
  6. Dictionary Cookie: This is a collection of key and value pairs. This is also called multi value cookie. When the website requires more than 20 cookies, this can be used.
Session Memory
  • Cookie can represent only plain text. If the requirement is representing objects unique to client, then this session memory is very useful.
  • When client makes a first request to application, web server will allocate a block of memory unique to each client. This is called Session Memory.
  • This session memory will be maintained on server with the timeout of 20 minutes. That is when client does not make a request for 20 minutes; the session memory will be erased.
Session Tracking
  • Session tracking is the concept of web server identifying session belonging to client. By default, it is implemented based on cookies concept.
  • When session is created for the client, the server will provide unique id for session. This is called session Id. This session id will be given to client browser in the form of cookie.
  • The session id will be 120-bit number in the hexadecimal format. The server will generate 2120 unique session ids.
  • When client makes subsequent requests to server, session id will be submitted based on which server will identify session belonging to client.

No comments:

Post a Comment