1. What is a Session?
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.
2. What is the default session timeout
period?
20 minutes.
3. Where do you generally specify the
Session Timeout?
You specify the Session Timeout setting in the web.config
file.
4. Can you specify Session Timeout in a code
behind file?
Yes, can specify the Session.Timeout property as
shown below in a code behind file.
Session.Timeout
= 10;
5. How do you end a user session?
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.
6. What type of
data can you store in Application State and Session State variables?
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.
7. Are
Application State or Session State variables type safe?
No, Application
and Session state variables are created on the fly, without variable name or
type checking.
8. Do
maintaining Session state affect performance?
Yes
9. Can you turn of
Session state?
Yes, Session
state can be turned off at the application and page levels.
10. Are Application
state variables available throughout the current process?
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.
11. How do you
disable Session state for a Web form?
To turn Session
state off for a Web form set EnableSessionState
property
of the Page to False.
12. How do you turn
Session state off for an entire web application?
In the Web.config
file,
set the sessionstate
tag
to False.
13. What are
Application State variables?
Application
State variables are global variables that are available from anywhere in the
application. All Sessions can access Application State variables.
14. How to add and
remove data to Application State Variables?
//Code to add
data to Application State
Application.Add("AppName",
"Sample");
//Code to
remove data from Application State
Application.Remove("AppName");
15. How do you
remove all Application State Variables data?
//Code to
remove all Application State Variables data
Application.RemoveAll();
16. What
are the different techniques to send data from one web form to another web
form?
1.
Query strings : Use these strings to pass information between
requests and responses as part of the Web address. Query strings are visible to
the user, so they should not contain secure information such as passwords.
2.
Cookies : Use cookies to store small amounts of
information on a client. Clients might refuse cookies, so your code has to
anticipate that possibility.
3.
Session state : Use Session state variables to store items that
you want keep local to the current session (single user).
4.
Application state : Use Application state variables to store items
that you want be available to all users of the application.
0 comments
Post a Comment