1. G. H. PATEL COLLEGE OF
ENGINEERING AND TECHNOLOGY
2160711 DOT NET TECHNOLOGY
ACADEMIC YEAR : 2018-19 (EVEN) (6th sem)
Group members :
JUSTIN PATEL 160110107039
MALAV PATEL 160110107040
Prof. Khyati Mehta
3. State Management Basic’s
• A Web Form / Page follows Stateless Model ie. The Server does not have
any information about who is requesting the page.
• Therefore to keep the Website more interactive we need to remember some
variables like username, items in cart for a shopping website, if the website
had the user has logged in once then we don’t have to make him login again
• To make the Website Stateful ASP.NET Framework provides various ways to
preserve the state of website.
4. Sate Management Methods
• Client Side Methods –
• Hidden Fields
• Query Strings
• Control State
• Server Side Methods
• Application State
• Session State
5. To Main Point – Session’s
• Session is Server side method for State Management.
• Session use Session Id to keep track of the user.
• Session Id are random strings generated by ASP.NET when the page is request by a
form submission or first entry.
• Session is defined in web.config to remember for 20 min by default.
6. How To Cookie-less Session
• In web.config file enable Cookieless to true to enable Cookie-less Sessions.
• <sessionState mode="InProc" cookieless="true"></sessionState>
• With is being done we will notice some funky change in our site URL.
• Default localhost:27858/WebForm1.aspx
• Cookieless Enabled
• This String is the Session Id which we were storing as a Cookie on Client Side to
remember Session on Server.
7. Points To Remember
• If Cookieless Enabled Then Session Id is passed back and forth in form of URL
• Server uses the Session Id to keep track of all the variables stored in
Session[“value”] object & Identifies the User.
• For Cookieless Session to work correctly relative URL are important no absolute
URL are allowed if we want Session object data.
• Eg. Response.Redirect(“~/WebForm2.aspx”); Allowed
• Response.Redirect(“http://xyz.com/WebForm2.aspx”); Not Allowed.
10. Application State
• We all know that the web uses the HTTP protocol and that the HTTP
protocol is a stateless protocol, in other words when a client sends a request
to the server, an instance of the page is created and the page is converted to
HTML format and then the server returns the response and then the
instance of the page and the value of the control is destroyed. So if we have
a requirement to store the value of controls then a State Management
technique is used.Server uses the Session Id to keep track of all the variables
stored in Session[“value”] object & Identifies the User.
11. Application State
• Application State is a state management technique. Application State is
stored in the memory of the the server and is faster than storing and
retrieving information in a database. Session state is specific for a single user
session, but Application State is for all users and sessions. Application State
does not have a default expiration period. When we close the worker process
the application object will be lost. Technically the data is shared amongst
users by a HTTPApplcationState class and the data can be stored here in a
key/value pair. It can also be accessed using the application property of the
12. Syntax of Application State
• Store information in application state:
Application[“name”] = “Justin”;
• Retrieve information from application state:
string str = Application[“name”].ToString();