State Management – State Management techniques are used to persist data between post-backs. State Management techniques can be divided in two categories :
Client State Management
Server State Management
Use when you need to store small amounts of information for a page that will post back to itself.
Syntax: ViewState[“Name”]=”I am a Software developer”
To get value from viewstate need to convert data
string Name = Viewstate[“Name”].tostring();
Viewstate is stored in hidden field as string in encrypted form.
Viewstate can be enabled/disabled at page level.
Use when you need to store small amounts of state information for a control between round trips to the server.
Control state can not be modified
It can not be disabled
It can not be directly accessed
Use a hidden field only on pages that are submitted to the server.
It can store only single value as string.
Hidden fields are standard HTML controls that are easy to use.
Use when you need to store small amounts of information on the client.
These are two types : Persistent – They store in browser’s sub folder and remain till the manually deleted or automatically deleted based on time defined. Non-Persistent – They lost when user close browser.
Use query strings only if you are requesting the same page, or another page via a link.
They are not secure as they are visible in browser and hackers can tempered them.
Get value from querystring :
Use when you are storing infrequently changed, global information that is used by many users.
It is maintained in below events : Application_Start – Code that runs on application startup Application_End – Code that runs on application shutdown Application_Error – Code that runs when an unhandled error occurs Session_Start – Code that runs when a new session is started Session_End – Code that runs when a session ends.
Use when you are storing short-lived information that is specific to an individual session
There are four modes for session state : In Proc mode – It isdefault mode and is used to store data on the web server. State Server mode – It is used to store data in the Asp.Net State service. Session state does not lost when web application restarted and can be shared between multiple web servers in the web farming. SQL Server mode – It is used to store data in the SQL Server. Session state does not lost when web application restarted and can be shared between multiple web servers in the web farming. Custom mode – It is used to store data in custome location.
Use when you are storing user-specific information that needs to be persisted after the user session is expired and needs to be retrieved again on subsequent visits to your application.
Use when you are storing large amounts of information, managing transactions, or the information must survive application and session restarts.
Abstract classes have some implemented functionality so you can use the same functionality among all your implementations. Its the best example of re-usability of code. While Interfaces don’t provide any implementation of code.
If you are thinking about multiple version of your component then create abstract class. Abstract classes provide a simple and easy way to version your component. By updating base class, all the inheriting classes are automatically updated. While Interfaces can not be changed once created. Interfaces needs to be recreated.
Abstract classes are useful for large scale functionality While interface are useful in Small scale of functionality.
It means methods are declared with same name but different parameters (signatures).
It is also called compile time and early binding.
public class Overloading
public int CalculateAmt(int a, int b) //Method with two int type Parameters.
return a + b;
public int CalculateAmt(int a, int b, int c) //Same method name with different parameters.
return a * b * c;
It means methods are declared with same name and same parameters (signatures).
it is also called run time and late binding.
Method overriding is only possible in derived class.
Method overriding is not possible in the same class.
Only virtual and abstract methods in the base class can be overrides in derived class.
public class Math
public virtual int CalculateAmt(int a, int b)
return a + b;
public class Calculator:Math
public override int CalculateAmt(int a, int b)
return a * b;
When multiple users attempt to modify data at the same time, controls need to be established in order to prevent one user’s modifications from adversely affecting modifications from simultaneous users. The system of handling what happens in this situation is called concurrency control.
Types of Concurrency Control
Three common ways to manage concurrency in a database:
Pessimistic concurrency control: A row is unavailable to users from the time the record is fetched until it is updated in the database.
Optimistic concurrency control: A row is unavailable to other users only while the data is actually being updated. The update examines the row in the database and determines whether any changes have been made. Attempting to update a record that has already been changed results in a concurrency violation.
“Last in wins”: A row is unavailable to other users only while the data is actually being updated. However, no effort is made to compare updates against the original record; the record is simply written out, potentially overwriting any changes made by other users since you last refreshed the records.
A web application resides in the server and serves the clients requests over internet. The client access the web page using browser from his machine. When a client makes a request, it receives the result in the form of HTML which are interpreted and displayed by the browser.
A web application on the server side runs under the management of Microsoft Internet Information Services (IIS). IIS passes the request received from client to the application. The application returns the requested result in the form of HTML to IIS, which in turn, sends the result to the client.