Session State in Asp.Net OverView
Unlike cookies, session state has no size limitation .You can store gigabytes of data in session state. You can store a Dataset or a custom shopping cart object in session state.
You can’t really use a cookie to store a shopping cart a cookie is just too small and too simple
Like cookies, items stored in session state are copied to particular user. You can use session state to store user preferences or other user-specific data across multiple page requests.
Lables : Gridview ,Check/Uncheck Checkbox in Gridview
Lables : Gridview ,Check/Uncheck Checkbox in Gridview
You add items to session state by session object
When you use session state, a session cookie named “ASP.Net_SessionId” is added to your browser automatically .This cookie contains a unique identifier. It is used to track you as you move from page to page.
When you add items to the session object, the items are stored on the web server and not the web browser. The ASP.Net_SessionId cookie is used to associate the correct data to the correct user.
By default, if cookies are disabled, session state does not work. You don’t receive an error, but items that you add to session state aren’t available when you attempt to retrieve them in later page requests.
By default, Asp.net framework assumes that a user has left the website when the user has not requested a page for more than 20minutes.At that point, any data stored in session state for the user is discarded.
You can use session state to create a user-relative cache.
Eg: You can load data for a user and enable the user to sort or filter the data.
Using session object:
The main application programming interface for working with session state is the
“httpsessionstate class” .This object is exposed by
1) Page.Session
2) Context.session
3) Usercontrol.session
4) Webservice.session
5) Application.session
This means that you can access session state property from just about anywhere
Http session state class properties:
Cookie mode : Enables you to specify whether cookie less sessions are enabled
Possible values are Auto detect, Use cookies, use device profile
Count : Enables you to retrieve number of items in session state.
Icookieless : Enables to determine whether cookie less sessions are enabled.
Isnewsession : Enables to determine whether a new user session was created with the
Current user request.
Isreadonly : Enables to determine whether session state is read only.
Keys : Enables to retrieve list of items name stored in session state.
Mode : Enables you to determine the current session state store provider possible values are Custom, Inproc, Off, SqlServer and State server.
SessionId : Enables you to retrieve the unique Identifier.
TimeOut : Enables you to specify the amount of time in minutes before the web server assumes that the user has left and discards the session.
Maximum time : 525,600.
HttpSessionStateObjectMethods :
Abandon : Enables you to end the user session.
Clear : Enabled you to clear all items from session state.
Remove : Enables you to remove a particular item from session state.
Session Events :
Two events related to session state that you can handle in Global.asax file :
1) Session Start Event.
2) Session End Event.
The session start event is raised when ever user session begins.You can handle this event to load user information from the database.
The session End event is raised when a session ends. A session comes to an end,
When it times out because of user inactivity or when it is explicitly ended with the session. Abandon ( ).
-à When new session begins
Session start event is raised and session count is incremented by 1.
-à When session ends
Session End event is raised and session count is decremented by 1.
Session count variable is stored in Application State.
Application state contains items that are shared among all the users of a web application.
Note : Application object is locked before it is modified you must lock and unlock the application object because multiple users could potentially access the same items in application state at the same time.
Subscribe to:
Post Comments (Atom)
Labels
- Abstraction in Object Oriented Programming (OOPS) Concept (1)
- Access ChildControls in Gridview using Javascript (1)
- Add a WCF Service Reference to the Client (1)
- ASP.Net GridView Highlight Row onmouseover (1)
- ASP.NET View State And ViewStateEncryptionModes Overview (1)
- Calling Javascript From Any Part Of Code Behind Page By Registering The Script (1)
- Check And UnCheck CheckBoxes In Gridview using javascript (1)
- contact your server administrator. (1)
- DataControlField class (1)
- DataKeys ID (Identity Column) in Child Controls events in GridView (1)
- DataList Paging With PagedDataSource (1)
- Declaring Session in Asp.Net (1)
- Difference between Struct and Class (1)
- Displaying Images In GridView From DataBase (1)
- Dynamic Sitemaps in ASP.NET (1)
- Err: You must install Office SharePoint Server 2007 – Please read Microsoft Knowledge Base article: 962935 with the most recent service pack (1)
- GridView Class (1)
- Gridview Inside GridView (1)
- Gridview Paging using C# (1)
- Gridview Sorting Using C# (1)
- GridView.RowDataBound EventEvent (1)
- GridViewRow (1)
- Inserting Images To Database And Display in GridView (1)
- Microsoft Office Sharepoint Server 2007 on Windows Server 2008 – This Program is blocked due to compatibility issues (1)
- ModalPopUp Using CSS and Div To Reduce the Weight On WebPage (1)
- Session State in Asp.Net OverView (1)
- SharePoint 2010 – The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information (1)
- Tooltip GridView Header (1)
- Tree View Menu Control (1)
- WCF Service (12)
- What is Encapsulation in OOPS? (1)
Topics
- Abstraction in Object Oriented Programming (OOPS) Concept (1)
- Access ChildControls in Gridview using Javascript (1)
- Add a WCF Service Reference to the Client (1)
- ASP.Net GridView Highlight Row onmouseover (1)
- ASP.NET View State And ViewStateEncryptionModes Overview (1)
- Calling Javascript From Any Part Of Code Behind Page By Registering The Script (1)
- Check And UnCheck CheckBoxes In Gridview using javascript (1)
- contact your server administrator. (1)
- DataControlField class (1)
- DataKeys ID (Identity Column) in Child Controls events in GridView (1)
- DataList Paging With PagedDataSource (1)
- Declaring Session in Asp.Net (1)
- Difference between Struct and Class (1)
- Displaying Images In GridView From DataBase (1)
- Dynamic Sitemaps in ASP.NET (1)
- Err: You must install Office SharePoint Server 2007 – Please read Microsoft Knowledge Base article: 962935 with the most recent service pack (1)
- GridView Class (1)
- Gridview Inside GridView (1)
- Gridview Paging using C# (1)
- Gridview Sorting Using C# (1)
- GridView.RowDataBound EventEvent (1)
- GridViewRow (1)
- Inserting Images To Database And Display in GridView (1)
- Microsoft Office Sharepoint Server 2007 on Windows Server 2008 – This Program is blocked due to compatibility issues (1)
- ModalPopUp Using CSS and Div To Reduce the Weight On WebPage (1)
- Session State in Asp.Net OverView (1)
- SharePoint 2010 – The form cannot be rendered. This may be due to a misconfiguration of the Microsoft SharePoint Server State Service. For more information (1)
- Tooltip GridView Header (1)
- Tree View Menu Control (1)
- WCF Service (12)
- What is Encapsulation in OOPS? (1)
0 Responses to “Session State in Asp.Net OverView”
Post a Comment