State management interview questions part 1
1. What is State Management?
State management is a mechanism
to preserve state (i.e. state of a webpage, a control or an object etc.)
between subsequent requests to server from one or more clients. HTTP is a
stateless protocol by nature reason state management required.
In ecommerce application how you
can get current cart added product details or order details on confirmation
page, simply solution is using state management.
2. What are client based state management
The following list of state management options that
involve storing information either in the page or on the client computer.
1. View state
2. Control state
3. Hidden fields
5. Query strings
3. What are server side state management
The following list of state managment is ways to
maintain state information on the server.
1. Application state
2. Session state
3. Profile Properties
4. What is the difference between
Session.Clear() and Session.Abandon() in ASP.NET?
As we understand that Session is a Collection and it
stores data as Key/Value pair. So,
1. Session.Clear() clears all the session values
but doesn't destroy the Session. however,
2. Session.Abandon() destroys the session object.
In other words, Session.Clear() is like deleting all
files inside a folder (say "Root") but Session.Abandon() means
deleting the "Root" folder.
5. Can we Enable/Disable ViewState?
Yes, you can enable disable ViewState with different
ViewState for a specific control can be enabled or
disabled by setting EnableViewState property as follows:
aControl.EnableViewState = false;
Page Level :
We can enable/disable ViewState for a complete page as
<%@ Page Language="C#" EnableViewState="false" %>
For whole application, we can enable/disable views in
configuration file as follows:
6. What is stateless and statefull?
A stateless protocol is a communication protocol
treats each request as independent transaction and not related to any previous
A protocol which requires keeping of the internal
state on the server is known as a statefull protocol.
7. What is View state?
It is the mechanism or method that the ASP.NET page
framework uses to preserve page and control values between round trips.
This provides a dictionary object for retaining values
between multiple requests for the same page.
This is the default method that the page uses to
preserve page and control property values between round trips.
8. What is Control state?
The ControlState property allows you to persist
property information that is specific to a control and cannot be turned off
like the ViewState property.
9. What is Hidden field?
Hidden field control is used to store information,
which renders as a standard HTML hidden field. When a page is submitted to the
server, the content of a hidden field is sent in the HTTP form collection along
with the values of other controls.
10. What is Cookie?
A cookie is a small amount of data that is stored
either in a text file on the client file system or in-memory in the client
browser session. It contains site-specific information that the server sends to
the client along with page output. Cookies can be temporary (with specific
expiration times and dates) or persistent.