Microsoft.NET

……………………………………………….Expertise in .NET Technologies

Interview Questions on State Management

Posted by Ravi Varma Thumati on October 7, 2009

Q1 – Define Session, SessionId and Session State in ASP.NET.

Answer – A session is the duration of connectivity between a client and a server application.

SessionId is used to identify request from the browser. By default, value of SessionId is stored in a cookie. You can configure the application to store SessionId in the URL for a “cookieless” session.

Q2 – What is Session Identifier?

Answer – Session Identifier is used to identify session. It has SessionID property. When a page is requested, browser sends a cookie with a session identifier. This identifier is used by the web server to determine if it belongs to an existing session. If not, a Session ID (120 – bit string) is generated by the web server and sent along with the response.

Q3 – What are Advantages and disadvantages of using Session State?

Answer – The advantages of using session state are as follows:

  • It is easy to implement.
  • It ensures data durability, since session state retains data even if ASP.NET work process restarts as data in Session State is stored in other process space.  
  • It works in the multi-process configuration, thus ensures platform scalability.

The disadvantages of using session state are:

  • Since data in session state is stored in server memory, it is not advisable to use session state when working with large sum of data.
  • Session state variable stays in memory until you destroy it, so too many variables in the memory effect performance.

Q4 – What are the Session State Modes? Define each Session State mode supported by ASP.NET.

Answer – ASP.NET supports three Session State modes.

  • InProc
  • State Server
  • SQL Server

InProc Mode

  • This mode stores the session data in the ASP.NET worker process.
  • This is the fastest among all of the storage modes.
  • This mode effects performance if the amount of data to be stored is large.
  • If ASP.NET worker process recycles or application domain restarts, the session state will be lost.

State Server mode

  • In this mode, the session state is serialized and stored in memory in a separate process.
  • State Server can be maintained on a different system.
  • State Server mode involves overhead since it requires serialization and de-serialization of objects.
  • State Server mode is slower than InProc mode as this stores data in an external process.

SQL Server Mode

In this storage mode, the Session data is serialized and stored in a database table in the SQL Server database.

  • This is reliable and secures storage of a session state.
  • This mode can be used in the web farms.
  • It involves overhead in serialization and de-serialization of the objects.
  • SQL Server is more secure than the InProc or the State server mode.
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: