20 Most Popular Asp.net Core Interview Questions And Answers

In this post, we will discuss the 20 most popular Asp.net Core interview questions and answers. Prepare for your next Asp.net Core interview with our list of top 20 questions.

1) What is Asp.net Core?

Asp.net Core is a web development framework for building web applications on the .Net platform.
Asp.net Core is open source and can run on macOS, Linux, and Windows.


2) What is MVC?

MVC (Model – View – Controller) is an architectural pattern that separates an application into 3 main logical components, namely the Model, the View, and the Controller. Each component is built to handle specific development aspects of an application. MVC is the most popular industry standard for web application development.


3) What are the advantages of Asp.net Core?

  1. Command-Line support to build and run applications
  2. No web.config file. We have to store our configuration information in the appSettings.json file.
  3. No Global.asax file. We can register and use the services from the startup.cs file
  4. Built-in support for Dependency Injection.
  5. Built-in support for logging
  6.  Cross-platform
  7. Ability to deploy on more than one server like IIS, Docker, Apache, etc.
  8. Provides good support for asynchronous programming
  9. Supports Web Sockets and SignalR
  10. Protects against CSRF (Cross-Site Request Forgery)


4) What is Dependency Injection in Asp.net Core?

It is one of the design patterns.

It can be defined as passing dependency to other objects or frameworks (dependency injector). Dependency injection makes testing easier.

It can be done through the constructor.


5) Explain Middleware in Asp.net Core.

Middleware is a software component that is assembled into an application pipeline to handle requests and responses.
Each component chooses whether to pass the request on to the next component in the pipeline and can perform certain actions before and after the next component is invoked in the pipeline.


6) What are the different ways of doing Session Management?

  1. Session Variable
  2. ViewData
  3. TempData
  4. ViewBag


7) What are Cookies?

Cookies are text files with small pieces of data, which are stored in the end user’s browser, concerning that website or web application.


8) What are the different JSON files in the Asp.net Core application?

  1. global.json
  2. launchsettings.json
  3. appsettings.json
  4. bundleconfig.json
  5. bower.json
  6. package.json


9) What is the purpose of the wwwroot folder in Asp.net Core?

The wwwroot folder contains all static files like CSS, Images, JavaScript, and Html files which are served directly to the clients.


10) What are Razor Pages in Asp.net Core?

Razor Pages is a new aspect of ASP.NET Core MVC introduced in ASP.NET Core 2.0. It offers a “page-based” approach for building server-side rendered apps in ASP.NET Core and can coexist with “traditional” MVC or Web API controllers.


11) Explain Transient, Singleton, and Scoped lifetime services.

Transient lifetime services are created each time they are requested. This lifetime works best for lightweight, stateless services.

Singleton creates a single instance throughout the application. It creates the instance for the first time and reuses the same object in all calls.

Scoped lifetime services are created once per request within the scope. It is equivalent to a singleton in the current scope. For example, in MVC it creates one instance for each HTTP request, but it uses the same instance in the other calls within the same web request.


12) Explain Conventional and Attribute-based routing in Asp.net Core?

Conventional Routing establishes a convention for the URL path, such that given a template:

  • First token maps to a controller
  • Second token maps to an action
  • Third token maps to an optional id action parameter


Attribute Routing maps URLs by applying the routing template directly on the controller and action. The existence of a controller and action in the template is not mandatory for attribute routing as it doesn’t play any part in the routing process and it is recommended that you use this approach for most of your APIs. Furthermore, it will make your code more explicit and reduce routing errors that might be introduced as you add more controllers and actions.

public class ProductsController : Controller

13) What are the different return types of controller action methods?

  1. ViewResult
  2. PartialView
  3. Redirect
  4. RedirectToAction
  5. Content
  6. JSON
  7. JavaScript
  8. File


14) What is Content Negotiation in Asp.net Core Web API?

It is a mechanism where the client should be able to decide the format of the response from the server like if the client wants the response in either XML, JSON, HTML, etc.
For more visit Content Negotiation in Asp.net Core Web API


15) What is the difference between IQueryable and IEnumerable?

Both IQueryable and IEnumerable are interfaces to dotnet collections. IQueryable inherits from IEnumerable.

IEnumerable is an In-Memory collection, whereas IQueryable is a collection connected to DB via EF or LINQ.


16) What are URL Helpers?

  • Renders HTML links and Raw URLs
  • Generates links based on routing configuration
  • Helps to avoid hard-coded URLs.

<a href="@Url.Action("Login", "Account")">Login</a>


17) What are Tag Helpers?

  • Allows server-side code to be embedded within the HTML elements in Razor files.
  • Starts with asp-* to include model, action and controller info.
  • Supports HTML friendly development experience.

<a asp-action="Login" asp-controller="Account">Login</a>


18) What are Filters?

A Filter is an attribute class, which is executed before or after an action is executed. Filters are used to perform the following common functionalities:

  • Authentication
  • Authorization
  • Exception/Error handling
  • User Activity Logging
  • Data Caching
  • Data Compression


19) What are different types of Filters?

  • Authorization Filter
  • Resource Filter
  • Action Filter
  • Exception Filter
  • Result Filter


20) What is Area in Asp.net Core MVC?

Area is a feature that allows us to divide large application into small logical groups. Each Area has its own MVC structure by having subfolders for Models, Views, and Controller.

Don’t forget to check out Automate the Boring Stuff with Python Programming

Share on facebook
Share on twitter
Share on linkedin

Related articles