1)What is session?
   -Session is small block of memory maintained by website at server system
   -for every user separate session will be maintained
   -Each session can be tracked by using sessionid
2)What is the length of SessionId?
-120bit encrypted string
3)What type of data can be stored in the session?
-Any type of data can be stored
4)How much amount of data can be stored in Session?
-any amount of data can be stored
5)What is default location for session?
-In appDomain of website which is part process memory of asp.net worker process
      -for each website separate appDomain will be maintained
6)In asp.net page how can we access session data?
- By using Session collection
7)What is default timeout for session?
-20mins
8)How to transmit sessionid between client and server?
-sessionid can be transmitted in two ways
      1) By using cookie: sessionid will be transmitted by using a cookie called aspnet_sessionid
         Disadvantage:
            If browser does not support cookies or user has disabled the cookies then it is not possible to hold sessionid
      2) Modified URL: the sessionid will be attached to url of website, and then it is called as modified url or munged URL
9) How to configure session for application?
    -By using SessionState element in Web.config
       <system.Web>
        <sessionState mode="InProc" timeout="20" cookieless="false"/>
       </sessionState>
10)When session will be destroyed?
      -When ever session timeout period has been expired
       -When ever webserver has been restarted or web.config file content has been modified
      -Session can be destroyed intentionally by invoking Session.Abandon()
11)If user closes browser window, then is session of user is get destroyed or not?
-no, session memory is not destroyed. But user can not access session data. Once browser has been closed we are loosing sessionid so that session cannot be accessed.
     - Session memory will be destroyed once session timeout period has been expired
12)What are the events associated with session?
         1)Session_Start:it will be fired once session memory has been allocated
         2)Session_End:it will be fired before destroying  session memory by garbage collector
    Both these event handlers are defined in global.asax file
13)What is the difference between Session.Clear() and Session.Abandon()?
          -Session.Clear() will clear all items of session, but session memory is not destroyed. So that session_End event is not fired
          -Session, Abandon() will destroy the complete session memory so that Sesion_End  event will be fired
14)What are the different session modes?
    There are 5 modes
           1)Off: it will disable sessionstate for complete website
           2)InProc: it is default mode. Session memory will be allocated in appdomain of website
                       Advantage:
                               It gives better performance
                       Disadvantage:
                               -if traffic is more for website, session may not be maintained for specified timeout period.
                               -To allocate memory for new session older sessions will be destroyed automatically
           3)StateServer:Asp.net State server is windows service .some of sessions with simple data can be moved to state server
                       Disadvantage:
                            -only session with value types can be stored, but not reference types
           4)SqlServer:A session with any type of data can be stored in SqlServer TempDb tables temporary for longer time ,but they will be losted once sqlserver has been restarted
                       Disadvantage:                  
                            1. Extra burden of serialization and deserialization
                            2.It gives nearly 25% less performance as compared to InProc mode
           5) Custom: We can maintain session any type of data permanently by creating our own tables and database in sqlserver
                       Disadvantage:
                            1. Extra burden of serialization and deserialization
                            2. It gives nearly 25% less performance as compared to InProc mode      
15) Where can we use session data in our website?
  -in any webpage for same user
16) Is it possible to use session of asp.net website in asp website?
-yes, it is possible
17) How to disable sesionstate for a particular page?
-Goto source of .aspx
       <% Page language="cs" EnableSessionState="false"    %>
Thanks for visiting this blog. How is the content?. Your comment is great gift to my work. Cheers.
 
No comments:
Post a Comment