Sunday 22 December 2013

Session in Dot Net

                                                                                                                                                Next......


Q : What is a Session?
Ans : A Session is a unique instance of the browser. A single user can have multiple instances of the browser running on his or her machine. If each instance visits your Web application, each instance has a unique session.A session starts when a user accesses a page on a Web site for the first time, at which time they are assigned a unique session ID. The server stores the user's session ID in the Session.SessionID property.
Q : What is the default session timeout period?
Ans : 20 minutes.
Q : Where do you generally specify the Session Timeout?
Ans : You specify the Session Timeout setting in the web.config file.
Q : Can you specify Session Timeout in a code behind file?
Ans : Yes, can specify the Session.Timeout property as shown below in a code behind file. Session.Timeout = 10;
Q : How do you end a user session?
Ans : You can call the Session.Abandon() method to end a user session. If a user then tries to access a page the server will assign them a new session ID and it will clear all the previous session variables. You'll typically use Session.Abandon() on log-out pages.
Q : What type of data can you store in Application State and Session State variables?
Ans : Application State and Session State variables are used to store data that you want to keep for the lifetime of an application or for the lifetime of a session. You can store any type of data in the Application or Session state, including objects.
Q : Are Application State or Session State variables type safe?
Ans : No, Application and Session state variables are created on the fly, without variable name or type checking.
Q : Do maintaining Session state affects performance?
Ans : Yes
Q : Can you turn of Session state?
Ans : Yes, Session state can be turned off at the application and page levels.
Q : Are Application state variables available throughout the current process?
Ans : Yes, Application state variables are available throughout the current process, but not across processes. If an application is scaled to run on multiple servers or on multiple processors within a server, each process has its own Application state.
Q : How do you disable Session state for a Web form?
Ans : To turn Session state off for a Web form set EnableSessionState property of the Page to False.
Q : How do you turn Session state off for an entire web application?
Ans : In the Web.config file, set the sessionstate tag to False.
Q : What are Application State variables?
Ans : Application State variables are global variables that are available from anywhere in the application. All Sessions can access Application State variables.
Q : How to add and remove data to Application State Variables?
Ans ://Code to add data to Application State
Application.Add("AppName", "Sample");

//Code to remove data from Application State
Application.Remove("A ppName");
Q : How do you remove all Application State Variables data?
Ans : //Code to remove all Application State Variables data
Application.RemoveAll();

No comments:

Post a Comment

C# program Selection Sorting

Selection sort is a straightforward sorting algorithm. This algorithm search for the smallest number in the elements array and then swap i...