aspnet.jpg (2007 bytes)

ASP.NET State Management

In order to remember the information a user entered and not confuse with a second entry by other users across the world, all the data must be kept separate.  This is called managing session-state.  ASP.NET and even original ASP have ways of completing this.  In ASP.NET, every time a user accesses an .aspx page, an internal object called a Session is created.  The Session ID automatically remembers the data by placing in a browser cookie.  A simple example of a Session can be seen below.

Protected Sub Button1_Click(ByVal sender As System.Object, _
        ByVal e As System.EventArgs)_
        Handles Button1.Click

 Session(“DemoString”) = TextBox1().Text
 Response().Redirect(“Example.aspx”)

End Sub
 

ASP.NET automatically deleted sessions after a configurable timeout interval.  The programmer can also dump the Session by using the Session.Abandon method.

ASP.NET allows each application to specify the machine it wants the Session information to be stored.  In order to use this function, the programmer must use the stateConnectionString attribute in the web.config file.  The session information can also be stored in an SQL server by setting the mode attribute to sqlserver and providing the connection string in the SqlConnectionstring attribute.