Top 30+ ASP.NET Interview Questions and Answers

20 Aug 2022
23 min read  

    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 training & 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:

    • It uses C# and VB.NET languages to build the website.

    • It allows us to separate the HTML layout with server-side code.

    • It allows us to make the same class name qualifying under a different namespace.

    • ASP.NET pages are compiled, not interpreted.

    • ASP.NET is a request processing engine. It takes an incoming request and passes it through its internal pipeline to an endpoint where a developer can attach code to process that request.

  2. What is the difference between Web Site and a Web Application?

    There are the following differences between these two :

    Web Site

    • On a website, you cannot add multiple projects.

    • There is no project file (.csproj or .vbproj). All the files in a folder structure are automatically included on the site.

    • By default, compilation produces multiple assemblies.

    • The website is easy to create and deploy.

    • 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.

    • You cannot establish dependencies on the website.

    Web Application

    • In a web application, you can add multiple projects.

    • 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.

    • It is easy to develop compared to the website.

    • You cannot use different .NET languages in a Web Application such as C# and VB.NET both cannot be used in a web application.

    • You cannot edit a single file. Recompilation is required.

    • 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

    • You can establish dependencies in a Web Application.

  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.

  4. What is a Global.asax file?

    The Global.asax file has been derived from the HttpApplication class. The Global.asax file is used to add application-level logic and processing. It does neither handle any UI-related processing, nor it does support individual requests. It basically controls the following events.

    • 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.

    • Session level code and variables can be declared in the Application_Start event.

    • Application level events are for the entire application and may be used by any user.

    • Session level events are user-specific for the length of a session.

  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.


    • The Web.config is used to define application-level settings.

    • If any setting is not specified in Web.config it inherits from Machine.config by default.

    • Web.config is an XML-based configuration file for an ASP.NET application that includes the setting for Data Connection, Customizing Security, State Management, Memory Management, Error Handling, and much more.

    • It is sometimes called an application and session level configuration file.

    • You can have more than one Web.config file in your ASP.NET application.


    • This file is at the highest level in the configuration hierarchy.

    • You can find it at <WinDir>\Microsoft.NET\Framework\<version>\config\machine.config

    • Machine.config is used for defining server level settings.

    • 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.

    • It is automatically installed while installing Visual Studio.NET.

    • It is sometimes called a machine level configuration file.

    • Only one Machine.config file can be at the machine level.

  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.

     <add name="strcon" connectionString="Data Source=DonetApp; Initial Catalog=dotnetDB; Persist Security Info=True; User ID=asif@123; Password=123@asif" providerName="System.Data.SqlClient"/>
  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.

    • Load(PageLoad): The page load event is generally used to check postback and then sets control properties appropriately. After this event, the load event of child control is called.

    • ControlEvents(Postback): This event is called when a page or its controls causes postback such as ButtonClick event, SelectedIndexChanged event, CheckedChanged events, etc.

    • 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.

    • SaveStateComplete: Any changes to the page’s controls at this point are ignored here. This event is useful if you need to write processing that requires the view state to be set.

    • Render: In reality, it is not an event this is actually a method of a page object and its controls. At this point, controls are rendered in client-side HTML, DHTML, and scripts for the browser.

    • Unload: This event is used to clean up code you can use it to manually release resources.

  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.

  9. What is the difference between Hyperlink and LinkButton?

    Hyperlink control does not have the Click and Command events; whereas the LinkButton control has these events, which can be handled in the code-behind file of the Web page.

  10. What are navigation controls?

    Navigation controls help us to navigate in a Web application easily. These controls store all the links in a hierarchical or drop-down structure; thereby facilitating easy navigation in a Web application.

  11. How many navigation controls are in ASP.NET?

    There are three navigation controls in ASP.NET.

    • SiteMapPath

    • Menu

    • TreeView

  12. What is the difference between client-side and server-side validations?

    Client-side validations work at the client end with the help of scripting languages such as JavaScript or jQuery and VBScript. On the other hand, server-side validations work at the server end with the help of programming languages like C#, VB, F#, etc. Server validations work when you submit or send data to the server.

  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
    Built into .ascx file.
    Built into a redistributable assembly (i.e. a DLL).
    Generally used for static content.
    Generally used for dynamic content.
    It is easy to create and use as it inherits from server controls.
    Comparatively difficult because you have to develop from scratch.
    Can be only used with current applications.
    Can be used with any number of applications.
    Language dependent.
    Language independent, a control created in C# can be used in VB.NET.
    Cannot be added to the Visual Studio toolbox.
    Can be added to the Visual Studio toolbox.
  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.

    • Designing features to support those cultures and locales.

    • Writing code that functions equally well with all the supported cultures and locales.

      Localization is the process of customizing your application for a given culture or locale. In other words, Localization is the process of customizing your application in such a way that it behaves as per your current culture or locale. Typically, Localization translates your application UI into the current culture or locale.

  15. What is a Resource File?

    ASP.NET provides resource files to implement globalization and localization. The resource file is an XML file having extension resx. Each resource in the resx file is in the form of a key-value pair. For each culture that your application needs to support create a separate resource file. For example, WebResources.en.resx is a resource file for the English language, and WebResources.hi.resx is a resource file for the Hindi language.

  16. What are Local Resources and Global Resources?

    There are two types of resource files as given below :

    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.

  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.

  18. What are the differences between GridView and DataGrid?

    The differences between GridView and DataGrid are given below :

    It was introduced with ASP.NET 2.0
    It was introduced with ASP.NET 1.0
    Built-in supports for Paging and Sorting.
    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
    Built-in supports for Update and Delete operations.
    Need to write code for implementing Update and Delete operations.
    Supports auto format or style features.
    This feature is not supported.
    Performance is slow as compared to DataGrid
    Performance is fast as compared to GridView.
  19. What are the differences between ListView and Repeater?

    The differences between ListView and Repeater are given below :

    It was introduced with ASP.NET 3.5
    It was introduced with ASP.NET 1.0
    Built-in supports for paging and sorting.
    Need to write custom code.
    Built-in supports for Data grouping.
    Need to write custom code.
    Built-in supports for insert update and delete operation.
    Need to write custom code.
    Performance is slow as compared to Repeater
    Performance is fast as compared to ListView
  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.

    Off: Specify that Session state is not enabled.

    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.

    • SQL Server: In this mode, the session is stored in a SQL Server database. This also ensures that the session state will be available in the web application 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.

  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:

    • Require a stable environment to work within
    • Don’t require cross-platform support for your Web app
    • Have closer release schedules
    • Are previously continued working on an existing app and expanding its functionality
    • Already owns a team with ASP.NET skills

    What is the MVC pattern in ASP.NET?

    The Model-View-Controller (MVC) represents an architectural pattern that splits an application into 3 key logical components. The names of these components are the model, the view, and the controller. Keep in mind that this pattern is not related to the layered pattern. Essentially, the MVC pattern runs on the software side.

    In a particular application that implements the MVC pattern, every component comes with its role dedicated. To understand better, for example, model classes merely hold the data as well as the business logic. These classes don’t deal with the HTTP requests but they view only display information. Moreover, the controllers deal with and respond to user input and determine which model to be passed to which view. Doing this makes an application simple to develop and maintain as it expands in complexity.

  22. What is the NuGet package manager?

    NuGet is a package manager dedicated to the .NET ecosystem. Essentially, Microsoft developed it to offer access to thousands of packages being written by .NET developers. Also, you can use it for sharing the code you already wrote with others.

    A classic web application being developed through ASP.NET depends on several open-source NuGet packages to work. One of the famous NuGet package managers is Newtonsoft.Json. It is used for working with JSON data in .NET.

  23. How is the Program class useful in ASP.NET?

    Program.cs class signifies the entry point of our application. Any ASP.NET application begins identically as a console application, directly from a static void Main() function. It is this class that configures the web host which would serve the requests.

  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.

    Two methods involved in startup class are ConfigureServices() and Configure().

  25. What is a Kestrel?

    Kestrel is an open-source type cross-platform web server uniquely designed for ASP.NET Core. It is incorporated and enabled by default in ASP.NET Core. Moreover, it can be utilized as a web server processing requests straight from a network.

    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.

  26. What is dependency injection?

    Dependency injection represents a design pattern that assists to develop loosely coupled code. It is this pattern that is widely used in ASP.NET. The purpose of using Dependency injection is to provide the objects with what they need in the particular object’s constructor instead of needing that object to construct them.

    Dependency injection decreases and usually removes needless unnecessary dependencies between those objects that don’t require knowing one another. Also, it assists in testing by hitting out the dependencies at runtime.

    For implementing dependency injection, we can try multiple paterrns such as constructor injection pattern or property injection patterns to make it work effectively.

  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.

    CustomValidator: Useful for defining User Defined validation.

    Summary Validation: This shows a summary of all existing validation errors over an ASP.NET page.

  28. Explain the state management in ASP.NET:

    State management is a method to manage a state of a particular object on various requests. The HTTP protocol is the elementary protocol of the World Wide Web. It is a stateless protocol which means that each request is generated from a new user in accordance with a web server. In any web application, maintaining the state is vital.

    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.

    2 types of state management systems existing in ASP.NET are:

    1. Client-side state management
    2. Server-side state management

  29. Control State

  30. Session State

  31. Application State

  32. Control State

  33. Session State

  34. Application State

  35. What are the components of the web form in ASP.NET?

    Here is the brief of components of web forms in ASP.NET:

    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.


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.

Buy this eBook at a Discounted Price!

ASP.NET/AJAX Interview Questions & Answers eBook
Share Article
About Author
Shailendra Chauhan (Microsoft MVP, Founder & CEO at Scholarhat by DotNetTricks)

Shailendra Chauhan is the Founder and CEO at ScholarHat by DotNetTricks which is a brand when it comes to e-Learning. He provides training and consultation over an array of technologies like Cloud, .NET, Angular, React, Node, Microservices, Containers and Mobile Apps development. He has been awarded Microsoft MVP 8th time in a row (2016-2023). He has changed many lives with his writings and unique training programs. He has a number of most sought-after books to his name which has helped job aspirants in cracking tough interviews with ease.
Learn to Crack Your Technical Interview

Accept cookies & close this