ASPNET Interview Questions and Answers
ASPNET Interview Questions and Answers
Shailendra Chauhan
20 Aug 2022
18.5K Views
ASP.NET is an Open-Source web framework for building fast, secure web apps &
services with.Net. ASP.NET is also a cross-platform framework that has the biggest
draw that means, which can run on any operating system so this allows you to build
your ASP.NET web apps using HTML, CSS, Javascript, or Jquery. ASP.NET
1/18
training & asp.net interview question answer pdf allow you to build web API
that can be consumed with any other third party resources like Microsoft, Facebook,
or Google.
1. What is ASP.NET?
ASP.NET Framework is a part of the .NET framework used to create a dynamic
website, web application, and web services. It is a server-side technology that uses
all .NET compatible languages such as C#, VB.NET, J#, etc. which are compiled to
Microsoft Intermediate Language (MSIL). ASP.NET uses server control to develop a
rapid and interactive application in an easy way.
Any ASP.Net applications would also be written in multiple choice of .Net languages
that include C#, VB.Net, and J# and it provides multiple development modes, that
help to develop an application in an easy and better way.
Features of ASP.NET:
2/18
2. What
is the difference between Web Site and a Web
Application?
There are the following differences between these two :
Web Site
There is no project file (.csproj or .vbproj). All the files in a folder structure are
automatically included on the site.
You can use different .NET languages on a single web site such as VB.NET
pages and C# pages can be used on a single website.
You can edit a single page/file after deployment recompilation is not required.
Choose a website where one developer will responsible for creating and
managing an entire website. Since decoupling is not possible on the website.
Web Application
It has a Visual Studio project file (.csproj or .vbproj) stores information about
the project like as the list of files that are included in the project, and any
project-to-project references.
By default, compilation of code files (excluding .aspx and .ascx files) produces
a single assembly.
You cannot use different .NET languages in a Web Application such as C# and
VB.NET both cannot be used in a web application.
The right choice for enterprise environments where multiple developers work
for creating, testing, and deployment. Different groups work on various
components independently like one group work on the domain layer, other
work on the UI layer hence, decoupling is possible here
3/18
3. What is a round trip?
The trip of a Web page from the client to the server and then back to the client is
known as a round trip. In ASP.NET Response.Redirect() causes a round trip.
In other words, any web page that travels from the client-side to the server-side will
get processed on the server and travels back to the client, this whole process is called
a round trip.
Application_Start
Application_End
Session_Start
Session_End
Following are the important aspect of the use of the Global.asax file.
The code in the Global.asax is compiled when the web application is built for
the first time.
Application level events are for the entire application and may be used by any
user.
4/18
5. What
is the difference between Web.config and
Machine.config file?
Both files are used to define configurations for your ASP.NET application. There are
the following differences between these two configuration files.
Web.config
The Web.config is used to define application-level settings.
You can have more than one Web.config file in your ASP.NET application.
Machine.config
This file is at the highest level in the configuration hierarchy.
It defines the supported configuration file section and ASP.NET work process.
It registers providers that can be used for advanced features such as profiles
membership and role-based security.
5/18
6. How to define a connection string in the Web.config file?
Following is the way to define a connection string in Web.config for SQL Server
database.
<connectionStrings>
</connectionStrings>
6/18
7. What are various page events in ASP.NET?
Following are the page level events in ASP.NET.
PreInit: This is the first event of a page used to set values such as a master
page.
Init: This event fires after each control have been initialized. You can use this
event to change the initialized value of controls.
InitComplete: This event is raised after all initializations of a page and its
controls have been completed.
PreLoad: This event fires before the view state has been loaded for a page
and its controls and before page postback processing. This event is useful
when you need to write code after the page is initialized.
LoadComplete: At this event, all controls are loaded even after additional
processing can be done here.
PreRender: This event is taking place before the view state is saved also it
allows final changes to the page or its control.
Unload: This event is used to clean up code you can use it to manually release
resources.
7/18
8. What are server controls in ASP.NET?
The ASP.NET server controls are objects on the ASP.NET pages that run when the
Web page is requested. Many server controls, such as buttons and text boxes, are
similar to the HTML controls. In addition to the HTML controls, there are many
controls, which include complex behavior, such as the controls used to connect to
data sources and display data.
SiteMapPath
Menu
TreeView
8/18
13. What
is the difference between User Control and Custom
Control?
The differences between User Control and Custom Control are given below-
User Control
Custom Control
Language dependent.
9/18
14. What are Globalization and Localization?
Globalization is the process of designing and developing an application that
functions for multiple cultures or locales. In other words, Globalization is the
process of designing and developing an application in such a way that it can be used
by users of multiple cultures. Globalization makes your application ready for
international markets. This process involves:
Identifying the culture and locale that must be supported by the application.
Writing code that functions equally well with all the supported cultures and
locales.
Local Resources: Local resources are specific to a single web page and are used
for providing versions of a web page in different languages. These are stored in the
App_LocalResources folder.
Global Resources: Global resources are common for the whole web application
and can be accessed by all the web pages. These are stored in the
App_GlobalResources folder.
10/18
17. What are Neutral Culture, Culture, and Language?
A neutral culture is a culture that is associated with a language but not with a
country or region. For example, "en" for English and in for Hindi. Culture consists
of language and the country or region. It is denoted by culture code which contains
two lowercase letters denoting the language and two uppercase letters denoting the
country or region like as en-US for English in the US, en-GB for the UK, etc. A
language is any spoken language like English (en), Hindi (hi), and German (de), etc.
GridView
DataGrid
For sorting, you need to handle the SortCommand event and rebind grid required
and for paging, you need to handle the PageIndexChanged event and rebind grid
required
11/18
19. What are the differences between ListView and Repeater?
The differences between ListView and Repeater are given below :
ListView
Repeater
12/18
20. What
are the different modes for the Session state in
ASP.NET?
There are following the different modes of session states which can be defined in a
Web.config file.
InProc: This is the default mode of the session. In this mode session state is stored
on the web server i.e. IIS where an application is running.
OutProc: The OutProc mode can be handled by using the following ways -
State Server: In this mode, the session is stored in a separate process called
ASP.NET state service. This ensures that the session state will be available in
the web application and is restarted. This way also makes the session state
available to multiple web servers in a web farm.
Note: Session_End event of Global.asax is fired only in InProc session mode. The
object stored in the Session state must be serializable if the session mode is set to
OutProc.
13/18
21. When to opt for classic ASP.NET over ASP.NET Core?
Although it’s a better choice in nearly all the characteristics, you need not have to
switch to ASP.NET Core if you intend to maintain a legacy ASP.NET application that
is no longer actively developed.
It is better to choose ASP.NET over ASP.NET Core if
you:
14/18
24. How is the Startup class useful in ASP.NET?
This class deals with two significant aspects of your application. They are service
registration and middleware pipeline.
The Kestrel is a cross-platform web server built for the ASP.NET Core based on
"libuv" that is a cross-platform asynchronous I/O library which is a extremely fast
library.
15/18
27. What are the various validators in ASP.NET?
RequiredFieldValidator: This validator is used when you don’t want the
container to stay empty. It examines whether the control possesses any value or
not.
RangeValidator: It finds out whether the value in validated control falls the
specific range or not. CompareValidator: It tests if the value in controls matches
certain specific values or not. RegularExpressionValidator: Tests if the
particular value matches an explicit regular expression or not.
There are majorly four types of state management strategies available which are
given below.
-View State
-Control State
-Session State
-Application State
Above are the way to manage the state and all these are part of two categories which
are given below.
16/18
33. Session State
Server controls: They are Hypertext Markup Language (HTML) elements that
contain a runat=server attribute. These components provide automatic state
management as well as server-side events and react to the user events by
implementing an event handler on the server.
HTML controls: They also respond to
the related user events but the events processing takes place on the client machine.
Data controls: Data controls enable connection to the database, run commands, and
access data from a database.
System components: They offer access to system-level events that take place on the
server.
Summary
I hope these questions and answers will help you to crack your ASP.NET interview.
These interview questions have been taken from our newly released eBook
ASP.NET/AJAX Interview Questions & Answers. This book contains more than 110+
ASP.NET/AJAX interview questions.
This eBook has been written to make you confident in WCF with a solid foundation.
Also, this will help you to turn your programming into your profession. It's would be
equally helpful in your real projects or to crack your ASP.NET Interview.
17/18
18/18