State Management

  • Uploaded by: Justin Cook
  • 0
  • 0
  • June 2020
  • PDF

This document was uploaded by user and they confirmed that they have the permission to share it. If you are author or own the copyright of this book, please report to us by using this DMCA report form. Report DMCA


Overview

Download & View State Management as PDF for free.

More details

  • Words: 542
  • Pages: 7
State Management The connection between the client and the server will be closed once the response is returned to the client. This is called as stateless nature of the web. When the web server maintains the information about the client, then it is called as state management concept. 1. Submission of data using post method. 2. Cookies 3. Session memory 4. Application memory 5. Cache data (new in asp.net) Cookie Creating a cookie:

Dim obj as new httpCookie (“name”, value) Obj.expires=#mm/dd/yyyy/hh:mm:ss#(r equires incase of Persistent cookie) Response.appendcookie (obj)this will write cookie information to the client machine Reading the cookie: Dim obj as httpcookie Obj=request. Cookies (“name”)it returns an object of httpcookie class, if the obj is nothing then cookie is not available. Each request from the client will carry all the cookies information to web server.

The cookie information is maintained in the client machine, so it is called as client side state management. It does not provide any security because it is available in the client machine. So the client can modify the value of the cookie as well as delete the text file. Session Memory Using session object we can access the session memory. Session properties are, 1.Session id 2.Time out (To close session implicitly) Session methods are, 1.Add (varname, value) 2.Remove (varname) 3.Abandon (to close session explicitly)

When it comes to ASP 3.0, session variable can’t be removed, i.e. erased until session is closed. When it comes to ASP.NET, session variable can be removed by using remove method. Application memory When the first client’s first request comes to the web server towards a particular application, then web server will allocate memory for the application. This memory is called as application memory. This memory will be common to all the users. The application memory does not have timeout, this will be maintained till the web server is active. (i.e. executing)

E.g. At the time of chatting we require a common field i.e. application memory not the session memory. By using application object, we can access the application memory from the web page. Like session, application objects are having some methods. 1.Add (var, value) 2.Remove (var) 3.Lock () 4.Unlock () Each client request to the web server will start a new thread, when one thread is processing the data in the application memory before the processing is finished, if the time slice is completed the processor will go to next client request, if this thread is processing data

in the application memory, then the result will not be proper. To avoid this it is advisable to allow only one thread at a time to work with application memory. This can be achieved through lock () and Unlock () methods. This process is called as synchronization of threads. SESSION EVENTS AND APPLICATION EVENTS 1.Session OnStart () 2.Session OnEnd () When a session memory is created OnStart () event will be executed. Before releasing the session memory OnEnd () event will be executed.

Application Events are, 1.Application OnStart () 2.Application OnEnd () 3.Application BeginRequest () 4.Application EndRequest () (Newly provided in ASP.NET) When a request comes for a particular web page then begin request will be executed, then the particular requested page will be processed and then the end request will be executed.

Related Documents

State Management
June 2020 3
State
May 2020 26
State
June 2020 21
State
July 2020 19

More Documents from "satyakshi"