What is the difference between a session object and an application object?

A session object can persist information between HTTP requests for a particular user, whereas an application object can be used globally for all the users.

How do you change the timeout for a Session object?

You can change the timeout for a Session object by setting its Timeout property or by using the Web.Config file.

Define Session object.

The Session objects are non-persistent and it is not strongly typed. The Session objects uses the In Proc, Out Of Process or SQL Server Mode to store information. It is not only allowed for authenticated users but also allows to the unauthenticated users.

What is the difference between Session[“uname”]=TextBox1.Text and Session.Add(“uname”,TextBox1.Text)?

Session[“uname”]=TextBox1.Text and Session.Add(“uname”,TextBox1.Text) are both used to assign data from the TextBox1 to a key known as “uname”. Both commands will create a row in the Session Object.


Session[“uname”]=TextBox1.Text ; It uses an indexer to assign the data. The indexer refers to the particular row of the session object. The key “uname” is used to identify the row.
Assigning data using an indexer is faster and more efficient than assigning the data using the method–Session.Add(“uname”,TextBox1.Text)

Does SessionID change with every request in the asp.net 2.0 application?

For any web programmer, its obvious to think and believe that SessionId remains same through out the user session and it was right till asp.net1.1. But in asp.net2.0, this behavior has changed. In the asp.net application new sessionid is returned with the response to every request until session objects are not used.

According to MSDN the reason/solution is:

“When using cookie-based session state, ASP.NET does not allocate storage for session data until the Session object is used. As a result, a new session ID is generated for each page request until the session object is accessed. If your application requires a static session ID for the entire session, you can either implement the Session_Start method in the application’s Global.asax file and store data in the Session object to fix the session ID, or you can use code in another part of your application to explicitly store data in the Session object.”