Home MVC Interview Questions
Home MVC Interview Questions
Net SQL
Home
Asp.net
Page 1 of 33
MVC
Interview Questions
Its very difficult to predict what interviewer will ask during interview, right?
.
.
I think so, but I can assure that following are the best list of possible technical interview questions that Id
faced during my job interviews and also I asked as an interviewer in my professional carrier.
Tip: If you are appearing as an experienced developer in the interview, then Why do you want
to change the job? is the common question that may be ask before beginning of an interview
so prepare first and be clear while answering this question.
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Asp.net
Page 2 of 33
MVC
Interview Questions
if (IsPostBack)
{
//Page is Post Back
}
else
{
//Page is Not Post Back
}
}
3. What is the difference between ASP and ASP.NET?
Ans: ASP stands for Active Server Pages, also known as Classic ASP which is Microsofts server-side
technology and used to create dynamic and user-friendly web pages.
Asp.net was developed by Microsoft to allow programmers to build dynamic web sites, web applications or web
services. It is an open source server-side web application framework designed for Web development to produce
dynamic web pages.
The main difference between ASP and ASP.NET is that ASP is Interpreted Language because ASP uses
VBScript; whereas ASP.NET is Compiled Language because ASP.NET uses .NET Languages like C#, Vb.net,
which are compiled to MSIL (Microsoft Intermediate Language).
4. What is the lifespan for items stored in ViewState?
Ans: The lifespan of items stored in ViewState lives until the current page expiration including current page
post backs. When user requests another page, the previous page data are no longer available. In short, we
can say that the lifespan for items stored in ViewState exists till your current page exists.
5. Is .NET is Platform Independent? Yes or No?
Ans: It depends on different point of views. There are many of saying that .NET is Platform Independent,
Partially Dependent or Platform Dependent. But in my opinion, .NET is Platform Dependent because it
needs .NET Framework and Windows OS to run your application.
6. Which is the parent class used for the web server control?
Ans: The System.Web.UI.Control class is used for all the web server control.
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 3 of 33
Ans: The ViewState is a feature that is used by ASP.NET page framework to persist the page and server
Home
Asp.net
MVC
Interview Questions
The ViewState information is stored in the HTML hidden fields. It is automatically used by the ASP.NET page
framework to persist information that must be preserved between post backs. You can also use ViewState
to store application data that is specific to a page, like this:
//Store the values to ViewState
ViewState["testVS"] = txtID.Text;
//Get the value from ViewStete
if (ViewState["testVS"] != null)
{
txtID.Text = ViewState["testVS"].ToString();
}
8. What is the use of App_Code folder in Asp.net website?
Ans: When you create website from Visual Studio, the App_Code folder will automatically created in the
website root directory, otherwise you need to add it by right clicking on the project. We can use it to store
the files that we want to use in our website, like common classes, text files, pdf files, email templates,
reports etc.
9. What is the difference between DataSet and DataReader?
Ans: The DataSet has read/write access, we can update records; whereas DataReader has read-only access,
we cant update records.
The DataSet supports both forward and backward scanning of data; whereas DataReader supports forwardonly scanning of data. Read More
10. What is the difference between DataSet and DataTable?
Ans: A DataSet contains a collection of one or more database tables which resides in-memory; whereas A
Tip: I can understand how difficult to be appear in an interview for freshers or a little
experienced developers? So, my suggestion is to keep calm and do your best with whatever you
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 4 of 33
impact on interviewer and feels that he/she can perform best during his/her training period or
employment.
Home
Asp.net
MVC
Interview Questions
Session
QueryString
13. What is SQL Injection? How we can prevent it?
Ans: The SQL Injection Attack is a technique of insertion or injection of a SQL queries via webpage or web
form input controls. SQL injection attacks are a type of injection attack, in which SQL commands are injected
into data-plane input in order to effect the execution of predefined SQL commands. It means altering SQL
commands into SQL statements, and modifies database tables or data with using SQL Statements like Insert,
Update or Delete.
We can prevent SQL Injection Attack by using Parameterized SQL Statements. You can get more details with
step-by-step guide and example by go through the Read More link. Read More
14. What is the difference between String and StringBuilder?
Ans: A String is immutable, meaning that once you created string object then you cant modify it; whereas
A StringBuilder is mutable, meaning that once you created string builder object then you can modify or
append without creating a new instance for every time.
In String, Any operation that appears to change the string, it creates a new instance of string type in
memory; whereas In StringBuilder, Any operation that appears to modify or append new string, it doesnt
create a new instance of string type in memory. Read More
15. What is the difference between string and String?
Ans: Technically there is no difference between both of them. In general, string is an alias for System.String.
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Home
Asp.net
Page 5 of 33
MVC
Interview Questions
Ans: The DataAdapter is a part of ADO.NET Data Provider. It provides the communication between the
DataSet and DataSource.
We can use DataAdapter in combination with the DataSet objects for data access and manipulation
capabilities. The DataAdapter uses the SELECT statement to FILL a DataSet or DataTable and other DML
statements like INSERT, UPDATE, and DELETE to make modification to DataSource.
17. Which method of DataAdapter is use to load data to DataSet or DataTable?
Ans: The Fill() method of DataAdapter is use to fill or load the data to DataSet or DataTable, like da.Fill(dt). If
you want to check complete example of insert, update, delete including this method, please check here.
18. What is IIS? What is the use of IIS?
Ans: The IIS stands for Internet Information Services which is created by Microsoft to provide Internet based
services to your ASP.NET web applications. It is use to host your web applications on the server. It makes
your local computer to work as a web server which provides functionality to deploy one or more web
applications on the server.
19. What is the difference between ExecuteReader, ExecuteNonQuery and ExecuteScalar?
Ans: The ExecuteReader is generally used to get or read data from result set so its appropriate with SELECT
Command.
The ExecuteNonQuery is generally used when we want to perform any operation on result set so its
appropriate with INSERT, UPDATE, and DELETE Command.
The ExecuteScalar is generally used when we need only first value of result set or aggregate functions like
SUM, COUNT, and AVG etc in SELECT Command. Read More
20. ExecuteScalar returns what?
Ans: The ExecuteScalar returns the first column of the first row from the result set returned by the query,
additional rows and columns will be ignore from the result set. It will return null reference if result set is
empty.
21. ExecuteNonQuery returns what?
Ans: The ExecuteNonQuery returns int value as no of row(s) affected. For example, When you are inserting
records, you can see 1 row(s) affected, 5 row(s) affected etc.
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 6 of 33
Ans: The User-Defined Function can be used in SQL statements anywhere in the WHERE, HAVING, or SELECT
Home
Asp.net
MVC
Interview Questions
section; whereas the Stored Procedure cannot be used like this, we can use EXEC statement to execute
stored procedure. Following are some other differences between them:
Stored Procedure:
It can be used to Read and Modify data
It cannot be used to create constraints while creating a table
It can return 0 or n number of values; and which is OPTIONAL
It can have Input as well as Output parameters
It supports Transaction Management
It cannot be called from Function
It can allow SELECT as well as DML statements such as INSERT, UPDATE, or DELETE
We can use try-catch block to handle exception
User-Defined Function:
It can only Read data
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 7 of 33
A UNIQUE KEY constraint enforces the entity integrity and the uniqueness of the values in a set of columns;
so no duplicate values are entered.
Home
Asp.net
MVC
Interview Questions
On the other hand, FOREIGN KEY constraints are used to enforce referential integrity. A Foreign Key in one
table points to a primary key or unique key on another related database table. It prevent actions that would
change rows with foreign key values when there are no primary keys in related table with that same value.
25. What is QueryString? What are the Advantages and Disadvantages of using it?
Ans: The QueryString is use to send the one page information and values to another page on the server. If
you want to check the example, you can see complete querystring example to pass information between
pages here.
Advantages:
No external server resources are required so no extra overhead on the server
Supported by all the browsers without having issue
We dont need to put extra efforts in existing code so it is easy to use
Disadvantages:
All the attributes and values are visible to the end user, which leads to security threads
There is a limit to a URL length of 255 characters
26. What are the differences between PRIMARY KEY and UNIQUE KEY?
Ans: A PRIMARY KEY is also a UNIQUE KEY internally, but a primary key cannot allow NULL values; whereas
UNIQUE KEY allows a single NULL value but does not allows multiple NULL values over the columns.
Following are some other differences between them:
Primary Key:
A primary key can be only once in a table
A primary key never allow NULL values
A primary key is a unique key identifier and cannot be NULL and must be UNIQUE
Unique Key:
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 8 of 33
Ans: A NOT NULL constraint enforces that the column will not allow or accept NULL values. It is used to
enforce domain integrity.
Home
Asp.net
MVC
Interview Questions
Framework Class Library (FCL): The .NET Framework Class Library is a comprehensive,
object-oriented collection of reusable types that you can use to develop applications.
The .NET Framework class library includes ADO.NET, ASP.NET, and Windows Forms. It has a
collection of 7000+ classes and data type that enable .NET applications to access databases,
read & write files, processing XML, GUI, drawing, web services and many more. Some of the
examples are System.Data, System.Web, System.SqlClient etc.
Common Language Runtime (CLR): The CLR is the execution engine for .NET applications
& servers as the interface between .NET applications and the operating system. Following are
the key features of the CLR:
Loads & execute code, which includes conversion of intermediate language to native
machine code
Separates process and memory
Memory and Objects Management
29. Explain ASP.NET Page Life Cycle.
Ans: When a page is requested, it is loaded into the server memory, processed and sent to the browser.
Then it is unloaded from the memory. At each of this steps, methods and events are available, which could
be overridden according to the need of the application. In other words, you can write your own code to
override the default code.
When we execute an ASP.NET Webpage, it passes through the following stages which we can call Page Life
Cycle:
Page Request: When the page is requested by a user, ASP.NET determines whether the page
needs to be parsed and compiled or whether a cached version of the page can be sent in
response without running the page. The page request done before the page life cycle starts.
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 9 of 33
Start: In this stage, the Request and Response objects are set. If the request is an old request
Home
Asp.net
MVC
Interview Questions
or post back, the IsPostBack property of the page is set to true. The UICulture property of the
page is also set.
Initialization: In this stage, the page initialize and the controls UniqueID property are set.
Load: In this stage, if the current request is a post back, control properties are loaded with
information recovered from view state and control state.
Validation: In this stage, if all server controls on the webpage validates and runs successfully,
the IsValid property of the page is set to true (which let you to post data on the server) else
set to false (which prevent you to post data on the server).
Postback Event Handling: In this stage, if the request is a post back, the related event
handler is called.
Rendering: Before rendering, ViewState is saved for the page and all controls. During the
rendering stage, the page calls the Render method for each control, providing a text writer
that writes its output to the OutputStream object of the pages Response property.
Unload: In this stage, the rendered page is sent to the client and page properties, such as
PreInit: The PreInit is the first event in page life cycle. It checks the IsPostBack property and
determines whether the page is a postback. It sets the themes and master pages, creates
dynamic controls and gets and sets profile property values. This event can be handled by
overloading the OnPreInit method or creating a Page_PreInit handler.
InitComplete: The InitComplete event fires when all the controls turn on view state tracking.
LoadViewState: The LoadViewState event fires when the view state is loading.
LoadPostData: The LoadPostData event fires when the post back data is processing.
PreLoad: The PreLoad event fires after the page loads view state for itself and all controls,
and after it processes post back data that is included with the Request instance.
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 10 of 33
Control events: Use these events to handle specific control events, such as a Button
Home
Asp.net
MVC
Interview Questions
LoadComplete: The LoadComplete event fires at the end of the event-handling stage. When
the loading process is completed, control event handlers are run and page validation takes
place. This event can be handled by overloading the OnLoadComplete method or creating a
Page_LoadComplete handler.
PreRender: The PreRender event fire just before the output is rendered. By handling this
event, pages and controls can perform any updates before the output is rendered.
PreRenderComplete: The PreRenderComplete event fires just after each data bound control
whose DataSourceID property is set calls its DataBind method.
SaveStateComplete: The SaveStateComplete event fires after view state and control state
have been saved for the page and for all controls. Any changes to the page or controls at this
point affect rendering, but the changes will not be retrieved on the next post back.
Render: Actually Render is not an event; but at this stage, the Page object calls this method
on each control. All the server controls have a Render method that writes out the controls
markup to send to the browser.
Unload: The Unload event fires when the page is destroying the instances of the server
controls.
31. What is the difference between C and C++?
Ans: C is a Procedural-Paradigm Language; whereas C++ is a Multi-Paradigm Language, which means
procedural, functional as well as object oriented programming language.
Mapping between Data and Function is difficult and complicated in C; whereas In C++, Mapping between
Data and Function can be done using Objects. Read More
32. What is a DEFAULT Constraint?
Ans: A DEFAULT constraint is used to add values into a column when values were omitted. It will take the
default value (which we can specify during table creation) and insert into that field when no value is inserted for
that field. The DEFAULT values can be in form of integer, bool or datetime fields but cannot be defined
on TIMESTAMP and IDENTITY columns.
33. What is Object?
Ans: An Object is a real-world entity that keeps together property states and behaviors. To see an example,
Read More from here.
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 11 of 33
Ans: A Class is a collection of objects and represents description of objects that share same attributes and
Home
Asp.net
MVC
Interview Questions
actions. It contains characteristics of the objects such as objects attributes, actions or behaviors. To see an
example, Read More from here.
35. What is Method?
Ans: A Method is an objects behavior. To see an example, Read More from here.
36. What is the difference between DELETE and TRUNCATE?
Ans: A DELETE command removes the rows from a table on the basis of the condition that we provide
within WHERE clause; whereas a TRUNCATE command will remove all of the rows from a table. A DELETE
command is a DML statement; whereas a TRUNCATE command is a DDL statement.
TRUNCATE command Resets the IDENTITY Field of the table while removing all the rows from the table
but the table columns, constraints, indexes, permissions, and structures remains as it is.
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Home
Asp.net
Page 12 of 33
MVC
Interview Questions
Ans: An Abstraction is the process of providing only essential information to the outside real world and
hiding overall background details to present an object. It relies on the separation of interface and
implementation. To see an example, Read More from here.
42. What is Information Hiding?
Ans: An Information Hiding concept restricts direct exposure of the data. Data is accessed indirectly using
safe mechanism, methods in case of programming object. Follow the example given in Abstraction.
43. What is Inheritance?
Ans: An Inheritance in OOP allows us to create a new class using an existing one meaning extending one
class to another. The main advantage of extending classes is that it provides a convenient way to reuse
existing fully tested code in different context thereby saving lots of time with existing coding and its model
style. To see an example, Read More from here.
44. What are Custom User Controls? How can you register it to a webpage?
Ans: The Custom User Controls are the controls that are defined by developers. These controls are a mixture
of custom behavior and predefined behavior. These controls works similar to other web server controls.
The @Register directive is used to register a custom server control to a webpage.
//Register control using following statement right after @ Page directive
<%@ Register TagPrefix="myASP" TagName="myControl" Namespace="MyApp.Controls"
Assembly="MyApp" %>
//You can use like this in your .aspx page..
<myASP:myControl runat="server"/>
45. What are the difference between Abstract Class and Interface?
Ans: Following are the difference between both of them:
Abstract Class:
Abstract class does not support multiple inheritance
Abstract class contains Data Member
Abstract class contains Constructors
An abstract class Contains both incomplete (abstract) and complete member
An abstract class can contain access modifiers for the subs, functions, properties
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Interface:
Home
Asp.net
Page 13 of 33
MVC
Interview Questions
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 14 of 33
CustomValidator: This checks the data entered using a client-side script or a server-side
code.
Home
Asp.net
MVC
Interview Questions
CompareValidator: This validation control ensure that the values in two different web server
controls are matched or not.
RangeValidator: This checks if entered data is according to the range of two values that is
specified in MinimumValue and MaximumValue property of this validation control.
RangeValidator: This allows user to display the summary of errors at one place in detail.
51. Which method is used to force all the validation controls to run?
Ans: The Page.Validate() method is used to force all the validation server controls to run and to perform
validation.
52. How many Web.config files can we add in single project?
Ans: There might be more than one Web.config files for a single project depending on the hierarchy levels of
the project folders so we can add mostly one Web.config file for each folder hierarchy level.
53. What is Boxing and Unboxing concepts in .NET?
Ans: A Boxing is a process of converting the value type into reference type; whereas an Unboxing is a reverse
process of it means converting reference type to value type.
// int (value type) is created on the "Stack"
int stackVar = 12;
// Boxing = int is created on the "Heap" (means reference type)
object boxedVar = stackVar;
// Unboxing = boxed int is unboxed from the heap and assigned to an int stack variable
int unBoxed = (int)boxedVar;
54. What are the difference between value type and reference type?
Ans: A Value Type stores its contents in memory allocated on the stack. When you created a value type, a
single space in memory is allocated to store the value and that variable directly holds a value; whereas a
Reference Types are used by a reference which holds a reference or address to the object but not the object
itself because reference types represents the address of the variable rather than the data itself, assigning a
reference variable to another doesnt copy the data.
Examples of reference types are Classes, Objects, Arrays, Indexers, and Interfaces etc; on the other hand,
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Home
Asp.net
Page 15 of 33
MVC
Interview Questions
//Here the space required for the 5 strings array which is allocated on the "Heap"
string[] arrHeap = new string[5];
55. What is the difference between GridView and DataGrid?
Ans: The GridView is a web control; whereas the DataGrid is a windows control.
GridView:
In GridView control, you can add paging, sorting, or editing capabilities with enabling simple
gridviews property
GridView has EditTemplates template to enable inline editing
DataGrid:
In DataGrid control, we need to add events for paging, sorting, or editing capabilities
DataGrid does not have EditTemplates template to enable inline editing
56. What is a Partial Class?
Ans: When web application is too complex, then there is possibility that multiple developers can work on same
modules to speed up development process. So in this situation instead of defining an entire class at once if
becomes more difficult to implement as well as understand, so we can split or divide the definition into multiple
classes by using partial keyword.
At compile or runtime, a compiler will group all the partial classes together and treat them as a single class.
There are a several advantages to use partial classes, such as developers can work on different parts of the
classes from different places without needing to share same physical files. Following is the simple example to
understand the concept of partial class:
public partial class student
{
public void GetStudentDetails()
{
//developer is working on student details module
}
//some other function for same modules..
}
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Home
Asp.net
Page 16 of 33
MVC
Interview Questions
In other words, Cookie is a lightweight executable program which the server posts to clients machines.
That includes the identity of the user at the first visit of the specific website and on second visit cookie is
used to validate the user for their authenticity. This is not the only use of Cookie but there are several
others. The Cookie.Discard property is set to true means Cookie is turn off for a webpage so it instructs the
client application not to save the Cookie on the users machine.
The values of a Cookie can be transferred between the users request and the servers response. The default
timeout for the Cookie is 30 minutes.
58. What is Session? What is the default timeout for a Session?
Ans: The Session object stores information about, or change settings for a user session. It is used for State
Management in ASP.NET. A Session starts when the browser first request a resources from within the
application; and ends when either browser closed or session timeout has been expired.
The default timeout for the Session is 20 minutes but you can change it from Web.config file or override
session timeout from IIS settings.
59. Can you change Session default timeout? If yes, How?
Ans: Yes, we can change the default session timeout from Web.config file. The session timeout is specified in
the Web.config file within sessionstate element. You can change the session timeout setting by changing the
value of timeout attribute of sessionstate element in Web.config file, like this:
<configuration>
<system.web>
<sessionState timeout="50"/>
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Home
Asp.net
Page 17 of 33
MVC
Interview Questions
Ans: The Web.config file contains configuration setting for a web application or project, such as Database
Connections, Error Page Settings, Session States, Error Handling, HttpHandlers, Security like Authorization
and Authentication, Culture Specific Settings etc.
61. What is the use of Global.asax file?
Ans: The Global.asax file is used to execute the application-level events and sets the application-level
variables. It contains application-level events, such as Application_Error, Application_Start,
Application_End, Session_Start, Session_End etc. You can also add custom event that is supported by
Global.asax file.
62. What is the difference between Normalization and De-normalization?
Ans: In the relational database design, the process of organizing data to minimize redundancy is called
Normalization. It usually involves dividing data into different tables and defining relationships between
the tables. The key feature of the Normalization is to eliminate the data redundancy and ensure the data
dependency.
On the other hand, the process of attempting to optimize the performance of a database by adding redundant
data is called De-normalization. It is sometimes necessary because current database management
systems implement the relational model poorly. The key feature of the De-normalization is to move from
higher to lower normal forms of database modeling in order to speed up database access.
63. What is a Stored Procedure? Explain its advantages.
Ans: A Stored Procedure is a set of SQL statements that have been previously created and stored into the
SQL server database to perform some operation, such as retrieving result set from tables, insert, update,
delete data etc. You can also use it to backup a database or perform other maintenance tasks on regular
intervals.
It can accept input parameters so that a single stored procedure can be used several times over that network by
several clients using different input data.
Advantages:
It can reduce network traffic; results in improved performance of website
It provides a public interface to a database
Group of all queries at the same location, making it easier for DBAs to see how the database
is queried and optimize it accordingly.
Reusability
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 18 of 33
Because scripts are in one location, updates and tracking of dependencies based on
schema changes becomes easier
Home
Asp.net
MVC
Interview Questions
Advantages:
website logic even dont try Stored Procedures for CRUD operations with complex logic. So, Stored Procedures
should be used in a minority of cases rather than be the standard tool for all queries in an application or website.
64. What is a Trigger? Explain Types of Trigger.
Ans: A Trigger is a special type of SQL procedure that initiates an action when an event like INSERT,
UPDATE, or DELETE occurs on an database table objects. A trigger cannot be called or executed directly;
DBMS automatically fires the trigger as a result of a data modification to the associated table or in the case
of DDL triggers to a DDL event in the database. There are 2 types of triggers:
1) DML Trigger It can be form of Instead of Trigger and After Trigger. The Instead of Triggers are fired in
place of the triggering action such as an INSERT, UPDATE, and DELETE; whereas the After Triggers execute
after the triggering action such as an INSERT, UPDATE, and DELETE.
2) DDL Trigger The DDL Trigger are fired against DDL statements like DROP, CREATE, and ALTER table.
These types of triggers are always After Triggers.
65. What is the difference between Triggers and Stored Procedures?
Ans: Triggers are similar to the stored procedures in that both consist of procedural logic that is stored at
the database level to perform some action with database objects. The Stored Procedures are explicitly
executed by invoking a call to the procedure; whereas the Triggers are implicitly executed by any events.
In addition, triggers can also execute stored procedures.
66. What is a view?
Ans: A view can be used to retrieve data as well as update or delete rows. It can be thought of a stored query
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 19 of 33
Home
Asp.net
MVC
Interview Questions
It provides a feature for developers to customize how users can logically view the data
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Home
Asp.net
Page 20 of 33
MVC
Interview Questions
Ans: The Content-page is a child page that can be inherited by a Master-page. The Content-page does not
have complete HTML source code; whereas the Master-page has complete HTML source code inside its
source file. In short, we can say that master page contains full html markup code that is used to display data
to the users on the web browser.
73. Explain Login Controls?
Ans: The Login Controls use the Membership system to authenticate a user credentials for a web
application. The Login Controls are built-in controls in ASP.NET for providing login functionalities to website
or web application. Following are the common controls available that are available within a login control.
Login Control: It provides a gui interface for user authentication. It consists of a set of
controls, such as TextBox, Label, Buttons etc.
LoginStatus Control: It shows a login link to users, who are not authenticated and logout
link, who are authenticated.
CreateUserWizard Control: It provides a gui interface to the user to register for the website
or web application.
LoginRecovery Control: It allows users to get back password through an email, if they
forget.
75. What are the templates can be used within Repeater Control?
Ans: The Repeater control contains the templates, such as HeaderTemplate, ItemTemplate,
SeparatorTemplate, AlternatingItemTemplate, FooterTemplate etc. To see an example, Read More from
here.
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 21 of 33
Ans: The @Page directive is responsible to assign page specific attributes for the page parser and the
Home
Asp.net
MVC
Interview Questions
compiler in an ASP.NET Application. Following is the simple example of @Page directive; which is the first
line of your .aspx web page.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs"
Inherits="Default" %>
77. What are the major built-in objects in ASP.NET?
Ans: Following are all the common built-in objects in ASP.NET that we can use frequently during website
development.
Request
Response
Data
Application
Server
Context
Session etc
78. What is an index?
Ans: An index is a physical structure that contains pointers that point to a physical location of the data. It is
possible to create an index on one or more columns of a table, and each index is given a name.
An index is an ordered list of the contents of a columns or a group of columns of a table, in that ROWID
indicates exactly where the record is stored in the table.
The users can see the index name but cannot see the indices themselves; they are just used to speed up queries.
An Index can give you improves query performance because a seek action (it means you can able to locate
records without having to examine every row to locate those records) occurs for retrieving records from your
table in a query. There are several key features of creating an index, few of them are:
Indices are created in an existing table to locate rows more quickly and efficiently
It is used to speed up queries
is a database object used by applications in the procedural logic to manipulate data in a row-
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Declare a cursor
Open a cursor
Home
Asp.net
Page 22 of 33
MVC
Interview Questions
hierarchical levels in a Website. For an example, if we are creating School Management System so there
should be several hierarchies of departments such as Student, Teacher, and Admin etc; In this case we can use
nested master pages.
section contains set of user-defined values for the whole web application. Following is the simple example that
specifies the ConnectionString and Email that we can use later throughout the project.
<configuration>
<appSettings>
<add key="ConnectionString" value="myConnectionString here.." />
<add key="Email" value="myemail@domain.dom"/>
</appSettings>
</configuration>
82. Web form belongs to which class from .NET Framework Class Library?
Ans: A Web form belongs to the System.Web.UI.Page Class from .NET Framework Class Library.
83. Which Data Type does the RangeValidator Control support?
Ans: Integer, String, Currency, Double, and Date.
84. What does the EnableViewState property do? Why do we want it to On or Off?
Ans: The EnableViewState property enables the ViewState property on the page. When the
EnableViewState property is set to false (means Off), the page does not store the users input during post
back requests of the webpage. On other hand, when this property is set to true (means On), the page saves
the users input between post back requests of the webpage. Following is the simple example that states
that the EnableViewState property is set to Off.
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 23 of 33
Home
Asp.net
MVC
Interview Questions
1. INNER JOIN: It also known as Equi Join because the WHERE statement generally
compares two columns from two tables with the = (that is a equivalence operator), most
commonly used type, many database systems use this as by default join. INNER JOIN returns
all the rows from both the tables where there is a match. In short, we can say that use it when
you are want to select only those rows that have values in common in the columns specified
in the ON clause, which is required. Following is the simple example of INNER JOIN which
perform join ON studid which can be match rows and common between both the tables:
Example:
2. LEFT JOIN: It returns all the rows from the LEFT table, even if there is no match in the
RIGHT table. Following is the simple example statement of LEFT JOIN:
Example:
3. RIGHT JOIN: It returns all the rows from the RIGHT table, even if there is no match in the
LEFT table. Following is the simple example statement of RIGHT JOIN:
Example:
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Home
Asp.net
Page 24 of 33
MVC
Interview Questions
Note: Itll return all the rows from the right table (Result), even if there is no match in the left table
(Student).
4. CROSS JOIN: It returns all the possible combinations of the result set from the listed
tables. This kind of join is usually not preferred as it may take a long time to retrieve data and
produce huge result set which may decrease the performance of the application.
Example:
5. SELF JOIN: A SELF JOIN is a join of a table with itself. A common use of this join is when
the table stores entities or records which have a hierarchical relationship between them. For
example, if you want to show name of the employee and corresponding manager as a pair,
student and corresponding faculty as a pair etc.
Example:
consisting of the presentation data (which contains the user interface elements, such as HTML and Web Server
Controls), and the second one consisting of the business logic (which contains the event-handling process to
handle the events that are fired by the controls). It also allows us to debug and trace the code.
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 25 of 33
The file that contains the presentation data has the .aspx extension, for example myFile.aspx; whereas the
Home
Asp.net
MVC
Interview Questions
file contains the business logic has the .cs or .vb extension depending upon the type of selected
Session Cookie: This type of Cookie resides on the client machine for a single session until
the user does not Logout.
Persistent Cookie: This type of Cookie resides on a users machine for a period specified for
it to expire, such as 1 day, 7 day, 1 month etc.
91. Which method do you use to kill explicitly a users session?
Ans: The Session.Abandon() method kills the user session explicitly. You can also use Session.Remove
(mySession) method to remove any specific one session OR Session.RemoveAll() method to remove all
the sessions.
92. List 3 or 4 common properties of all validation controls?
Ans: Following are the common properties that can be use for any validation control.
ControlToValidate
Text
ErrorMessage
ForeColor
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Home
Asp.net
Page 26 of 33
MVC
Interview Questions
Page_Init
Page_Load
Page_PreRender
Page_Unload
Page_Disposed
Page_Error etc.
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 27 of 33
Ans: The System Exception is thrown by Common Language Runtime (CLR); whereas the System
Home
Asp.net
MVC
Interview Questions
class:
It is a reference type
It can have destructor
All variables in classes are by default private
Good to be used from architecture view as it provides high flexibility
Null value can be assigned to a variable in a class
structure:
It is a value type
It cannot have destructor
All variables in structure are public
Good to be used for simple data structures
Null value assignment is not feasible in a structure
101. Explain the difference between Response.Redirect and Server.Transfer.
Ans: Following are the some common differences between a Response.Redirect and a Server.Transfer:
Response.Redirect:
It is used to redirect a user to another webpage or website permanently
It causes additional roundtrips to the server on each request
It is used to navigate within the same website as well as from one website to another
website
Since it has round-trips, it provides less response as compared to Response.Transfer
method
Server.Transfer:
It is used only to transfer .aspx pages but not website
It preserves server resources and avoids the unnecessary roundtrips to the server
It is only used to navigate within the same website and not outside website
Since it has no round-trips, it provides faster response and does not update the clients
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 28 of 33
Note: The round-trip is a process of a webpage from client to the server and then back from server to the
Home
Asp.net
MVC
Interview Questions
Destructors method called once an object is disposed, and can be used to cleanup resources used by the
object. Destructors dont look very much like other methods. To see an example, Read More from here.
105. Which ASP.NET objects encapsulate the state of the client and the browser?
Ans: The Session object encapsulates the state of the client and the web browser.
11
Shares
Share
Share
1
Pin
Tweet
Share
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
E-Mail Address
Home
Asp.net
Page 29 of 33
MVC
Interview Questions
Subscribe
Comments
Kumar says
Dec 24, 2015 at 3:17 PM
Nice article. Its helpful for Fresher to 2+ exp..
Reply
Reply
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Home
Asp.net
Page 30 of 33
MVC
Interview Questions
Reply
Reply
Email *
Website
Comment
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Submit Comment
Home
Page 31 of 33
Asp.net
MVC
Interview Questions
Search
1,624
Fans
4,610
48
Followers
Followers
21
Followers
1,080
Subscribers
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Home
Page 32 of 33
Asp.net
MVC
Interview Questions
Find by Tags
Ado.net Ajax appSettings
Asp.net C#
Subscribe
Newsletter
UploadTo
Validation
VB Web.config Web Hosting
Enter your email address to subscribe to this blog and
receive notifications of new posts right to your inbox
Join 1000+ other subscribers
E-Mail Address
Subscribe
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016
Page 33 of 33
Hot on AspnetO
Asp.net
MVC
Vb.net
7045 downloads
39.76 KB
6324 downloads
39.76 KB
11
Vb.net
Shares
Interview Questions
39.76 KB
3121 downloads
1.01 MB
3105 downloads
1.01 MB
http://www.aspneto.com/100-frequently-asked-interview-questions-on-asp-net-sql-server... 28-04-2016