In this session i will tell you about why session is important in Asp.Net and in other Technologies.
Description
State Management is a main thing for any Web Application on server . If you are working with Dynamic Websites then you can find the use of State Management Techniques.
What is State Management?
As we all know Http is a Stateless Protocol and our all application used http Protocol to run.So it is hard to manage their State on server. Means our control lost its value when postback happend (Postback : when our web page redirects to server after first load).In other words we can say State management means to preserve the state of a control, web page etc.
One of the most crucial concepts in Web Development is the State management. In a nutshell , when you request a page from ASP.NET, the Web Server receives it, process it and finally sends the response back to the browser, discarding all the previous Page information. You may ask yourself right now how is then possible to see several server controls, such as Text-Box ,Checkbox , Grid-View maintaining their values during Postbacks.
Well, those server controls, use the View-State Page property to maintain their state. You can understand all the sates used by Asp.Net in below description.
State Management Techniques
Asp.Net Provides Two types of State Management Techniques which are:
1 .Client Side State Mangement
2 .Server Side State Mangement
Client Side State Management :
1 . View State 2 . Control State 3 . Hidden Fields 4 . Cookies 5 . Query String
1. View State-
ViewState is one of the Client-Side State Management techniques that provides page-level state management, which means state is preserved between subsequent requests to same page.
Read more about View-State with Example
2.Control State -
Use control state only for small amounts of critical data that are essential for the control across postbacks. Do not use control state as an alternative to view state. Control state can store control state. By default, the Asp.Net framework stores control state in the page hidden field same as view state.
3. Hidden Fields -
The HiddenField control provides you a way to store information in the page without displaying it. For example, you might store a user-preference setting in a HiddenField control so that it can be read in client script.
Read more about Hidden-Fields with Example
4. Cookies -
A cookie is a small piece of text file stored on user's computer in the form of name-value pair. Cookies are used by websites to keep track of visitors e.g. to keep user information like username etc.
Read more about Cookies with Example
5.Query String -
The Query String collection retrieves the values of the variables in the HTTP query string.The HTTP query string is specified by the values following the question mark (?). Often you need to pass variable content between your html pages or aspx webforms in context of Asp.Net. For passing values between our aspx page or Web-Forms asp.net gives several ways. QueryString is one of them.
Read more about Query-String with Example
Server Side State Management :
1.Session State
2.Application State
3.Cache
4.Profile Properties
1.Session State -
Session State is one of the important state management variable in Asp.Net. It’s working on server side. Advantage of session state is that once you store your data in session and access that data from anywhere in the application across multiple pages .
Read more about Session-State with Example
2.Application State-
Application state is server side state management variable. Application state stored data in memory on the server. Application state is a great place to store data when you don’t want to track users and require your data to be available for the entire application.
0 comments:
Post a Comment