Thursday, March 21, 2013

State management in ASP.NET

asp.net tutorial state management
State Management in ASP.NET

ASP.NET offers a number of places to store state, both on the client and server. However, sometimes it's difficult to decide where you should put things and how to make that decision.

Choices for state management include:

Application
Cache
Session
ViewState
Cookies
QueryString
Context.Items
Profile


Types of State management


2 types:


  1. Client Side State Management
  2. Server - Side State Management



Client Side State Management:

Stores information on the client's computer 

Techniques:

1. View State:

  •  Stored in a hidden page input (by
  • default).
  •  Does not expire.
  •  Track the values in the Controls


2. Control State: 

created to ensure working of viewstate

3. Hidden fields

store data in an HTML form

4. Cookies:
  •  Stored at the client.
  •  Can expire.
  •  Store state data at client required on  multiple pages of website

5. Query Strings:
  • Passed in the URL.
  • Must be maintained with each request.
  • Store values in the URL that are visible to the user


Server Side State Management


1.Application State:
  • Stored on the server and shared for all users.
  •  Does not expire.
  •  Deprecated by Cache

2.Session State :
  • Stored on the server.
  •  Unique for each user.
  •  Can expire.
  •  Available to all pages opened by a user during a single visit.
ASP.NET session state supports several different storage options for session data:

a.
InProc Stores session state in memory on the Web server.

b.
StateServer Stores session state in a service called the ASP.NET State Service.

c.
SQLServer
Stores session state in a SQL Server database.

d. Custom Enables you to specify a custom storage provider. You also need to implement the custom storage provider.

e. Off Disables session state. You should disable session state if you are not using it to improve performance. 


0 comments:

Post a Comment