ASP.Net Interview Questions and Answers

Q. HTTP Handler vs HTTP Module in ASP.Net
HTTP handler is a process which runs against a HTTP request. Based on file extension HTTP handler executes. Custom HTTP handler can be created on specific requirement.

Generic Web handler (.ashx) - Default HTTP handler for all web handlers. It has no UI.

HTTP Modules-  It is involved in the life cycle of a request. In a request a there could be various stages like Security, Exception Logging etc.

Q. What is IsPostBack
IsPostBack is to check whether the page is rendered for the first time or being loaded in response to postback. It returns boolean value i.e. true or false.

Q. Difference between custom user control and user control.

Q. What is view state in ASP.Net
View state is used to maintain the state on a page when an HTTP request made.

Q. State Management in ASP.Net

Q. Response.Redirect vs Server.Transfer
Response.Redirect - It makes a round trip and next url is visible in browser.
Server.Transer - It does not make round trip and current url only is visible in browser. So no change in url. Server.Transfer takes 2 parameter, first is url and another is preserved form which is a bollean value. By default 2nd parameter is true.

System.Collections.Specialized.NameValueCollection prevForm = Request.Form;
string val = prevForm["txtName"];

Q. Cross Page Posting.
Cross page posting allows to post from one page to another page.
We can check cross page postback by using
To do this we need to set postback url property of a button.


Q. What is Global.asax file
It is an ASP.Net application file. Code written in Global.asax file works at Application level for eg - Application_Start, Application_End, Session_Start, Session_End

Q. How to access MasterPage control in child control

MasterPage.cs file:

 public string UserName
            return (String)Session["Name"];
            Session["Name"] = value;

Child ASPX Page -

  <%@ MasterType VirtualPath ="~/Site.master" %>

Child ASPX.CS Page -

Master.UserName = "My User Name";

Q. Authentication vs Authorization
Authentication is the process of verifying user identity.
Authorization is the process of identifying what access a user have.
Authentication occurs before Authorization.

Q. ExecuteScalar vs ExecuteNonQuery vs ExecuteReader

ExecuteNonQuery - Execute SQL statement and returns number of rows affected.

ExecuteScalar - It will return single value

ExecuteReader - It will return set of rows. This is read-only and forward-only.

Q. SQLDataReader
It is a forward-only way to read data from sql.
Read(), NextResult() are few method from SQLDataReader.

Note: In ADO we have recordset but in ADO.Net we have DataSet

Q. Two fundamentals object in ADO.Net
DataReader and DataSet

DataSet is a disconnected architecture , DataReader is a connected architecture.
DataSet contains more than one table.

Q. Methods of SQLDataAdapter
Fill() - Get table structure with data.
Update() -
FillSchema() - It creates just a blank table same as sql table structure

Q. Joins in SQL
Inner Join - Get the rows where there is a match in both the tables.

Left Outer Join - Get the rows from the first of left side table.

Right Outer join - Get the rows from the first of right side table.

Full Outer Join - Get all the rows in both the tables.

Cross join - Result is equal  to the number of rows in first table times the number of rows in the second table.

Self Join - Join a single table to itself, in this case you are using same table twice.

Union vs Union All - Union gets distinct value only. Union All allow duplicate values.

SQL Constraints - It is use to specify the rule for data in a table.
Following constraints are available in SQL- NOT NULL, UNIQUE, PRIMARY, FOREIGN KEY etc.

Q. Primary Key vs Foreign Key vs Unique Key
A table can have multiple unique and foreign keys. However, a table can have only one primary key.

Unique key columns are allowed to hold NULL values. Unique key can accept only one null value.
Foreign key can hold NULL values.

Q. Delete vs Truncate
Truncate Delete
1.Reset table to empty state. It is a DDL command.
2.Where clause can not be used with truncate command.
3. Faster than Delete
4. Rollback is not possible.
1.It is a DML command.
2. Where clause can be used with Delete command.
3. Slower than truncate.
4. Rollback is possible.

Q. View state vs Session
View state is applicable on a web page only, session is a global variable and applicable through out the site.
View state can be stored in client side only. Session can be stored on server also.
Viewstate is stored in a hidden control.

Q. Cast vs Convert in SQL
Cast can not be used for formatting purpose.
Cast can not convert a datetime to specific format.
Syntax - cast(@var,as date)

Convert is used to fomat data. Eg convert(varchar,datetime, 103)
convert(data_type,expression, style)

Q. Clustered and Non Clustered Index
Index is a object in database which can be created on or more than one columns
Indexing will read column and reform data in a relevant structure to minimize
the comparison which helps in searching a record.

Cluster index - It arrange tables in a physical order. Due to this reason a table can have only one clustered index.

To check cluster index on a table

Execute sp_helpindex tablename

By default a cluster index is applicable on table on primary key.
But we can change cluster index key.
To do this we need to delete the existing cluster index and write below query.

create clustered Index CLS_IDX_tble1_firstname_city on table1 (firstname desc, city asc)

It will create clustered index on table1 for firstname and city column. As it is applicable on more than one column, so it is called composite cluster index.
So, a table can have only one clustered index.

Non-clustered index - A table can have more than one non-clustered index. It uses row address to find the record.
Non-clustered index can be understand with index given in a text books.
Clustered index is faster than non-clustered index.

create NonClustered Index NIDX_tble1 on table1(firstname)

Q. Is it possible to use any other sign instead of $ in jquery

Normally we write code as below:

  <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
 $(document).ready(function () {



 jQuery(document).ready(function () {


To use any other character instead of $ we can write below code.

    <script type="text/javascript">
        var $y = jQuery.noConflict(); // or  var $y = $.noConflict();
        $y(document).ready(function () {




Popular posts from this blog

CAML Query in SharePoint 2010

Calling REST APi from server side code - C#

All about SharePoint 2010 Content Type Hub

SharePoint Interview Questions and Answers

Calling ASP.Net WebMethod using jQuery AJAX