Important Dot Net Core Interview Questions 2023

In this article, we will mostly be asked Dot net core interview questions and answers. Before that let’s understand some background about ASP.NET Core.

ASP.NET Core is a free, open-source, and cloud-optimized web framework that can run on Windows, Linux, or Mac. You can say that it is the new version of ASP.NET.

ASP.NET Core is designed to be deployed on the cloud as well as on-premises. Developers can now build cloud-based web applications, IoT (Internet of Things), and mobile backend applications using the ASP.NET Core framework which can run on Windows, Linux, and Mac operating systems.

You can check out the article on introduction to core to understand them in more detail. Let’s start with Dot net core interview questions.

Q 1. What is the ASP.NET Core

Q 2. Why do we need an ASP.NET Core or features of ASP.NET Core

Q 3. What is .NET Core

Many people are confused between ASP.NET Core and .NET Core. Please note that ASP.NET Core and .NET Core are not the same. They are different, just like ASP.NET and .NET Framework are different.

dotnet core interview questions

Q 4. What is the startup class in ASP.NET core

Q 5. What is the use of the ConfigureServices method

Q 6. What is the use of the Configure method

Q 7. What is middleware

Q 8. Difference between IApplicationBuilder.Use() and IApplicationBuilder.Run()

Q 9. What is routing in ASP.NET Core and types of routing

Routing in ASP.NET Core is the process of mapping incoming requests to application logic that are resides in controllers and methods.

ASP.NET Core maps the incoming request based on the routes that you configure in your application, and for each route, you can set specific configurations, such as default values, message handlers, constraints

Q 10. What are the JSON files available in ASP.NET Core

Q 11. What is dependency injection

Dependency Injection (DI): its a software design pattern that allows us to develop loosely coupled code. Dependency Injection is a great way to reduce tight coupling between software components. Dependency Injection also enables us to better manage future changesand other complexity in our software. The purpose of DI is to make code maintainable.

Tightly Coupling: The software components were dependent on each other in such a way that, for a small change in one component, you might need to change a lot in the dependent component. This is not good practice in software development. Simplest way to understand is when we get an instance by using a new keyword that class or service is tightly coupled.

Loosely Coupling: In this case, the software components slightly depend on each other. If we need to change one component then it will not affect much more on the dependent component. We can achieve this situation through interfaces. The classes can communicate with each other with the help of an interface. Service Lifetime

Q 12. What are the service lifetime

it is important to understand what is service lifetime. When we are registering our service then we need to register with the correct lifetime to define lifetime service issues or shares. The Built-in IoC container manages the lifetime of a registered service type. It automatically disposes a service instance based on the specified lifetime.

In core There are 3 options for this with the built-in DI container in ASP.NET Core:

Q 13. Can ASP.NET Core work with the .NET framework?

Yes. ASP.NET core application works with full .NET framework via the .NET standard library. We need to make use of .NET standard library make both application compatible with each other.

Q 14. Why do we need a program.cs file

In an ASP.NET Core project we have a file with name Program.cs. In this file we have core main method as public static void Main() method

The most important point that you need to keep in mind is, the ASP.NET Core Web Application initially starts as a Console Application and the Main() method is the entry point to the application. So, when we execute the ASP.NET Core Web application, first it looks for the Main() method and this is the method from where the execution starts. The Main() method then configures ASP.NET Core and starts it. At this point, the application becomes an ASP.NET Core web application.

Q 15. What is Kestrel

Kestrel is a cross-platform web server built for ASP.NET Core. It is based on asynchronous I/O library called “libuv” primarily developed for Node.js  It is default web server, but you still can use IIS, Apache, Nginx etc.

Usually, it is used as an edge-server, which means it is the server which faces the internet and handles HTTP web requests from clients directly. It is a listening server with a command-line interface. 

Advantages of Kestrel: 

Q 16. What is metapackages in .net cor

The framework .NET Core 2.0 introduced Metapackage that includes all the supported package by ASP.NET code with their dependencies into one package. It helps us to do fast development as we don’t require to include the individual ASP.NET Core packages. The assembly Microsoft.AspNetCore.All is a meta package provide by ASP.NET core.

Q 17. What is wwwroot folder in ASP.NET Core

In ASP.NET Core, all the static resources, such as CSS, JavaScript, and image files are kept under the wwwroot folder (default).

Static files are typically located in the web root (wwwroot) folder and its default place where we can serve up files directly from the file system when we create your core application

Q 18. How to enable Session in ASP.NET Core

public void ConfigureServices(IServiceCollection services)  
    services.AddSession(options => {  
        options.IdleTimeout = TimeSpan.FromMinutes(1);//You can set Time   
public void Configure(IApplicationBuilder app, IHostingEnvironment env)  
    app.UseMvc(routes =>  
            name: "default",  
            template: "{controller=Home}/{action=Index}/{id?}");  

Q 19. What is In-memory cache

With ASP.NET Core , it is now possible to cache the data within the application. In-memory cache is the simplest way of caching by ASP.NET Core that stores the data in memory on web server. This is known as In-Memory Caching in ASP.NET Core. It is a service that you can incorporate into your application using dependency injection. IMemoryCache interface instance in the constructor enables the In-memory caching service via ASP.NET Core dependency Injection .

Apps running on multiple server should ensure that sessions are sticky if they are using in-memory cache. Sticky Sessions responsible to redirect subsequent client requests to same server.

Q 20. How to enable the in-memory cache in ASP.NET Core project

You can enable the in-memory cache in the ConfigureServices method in the Startup class.

public void ConfigureServices(IServiceCollection services)  

Please check below video version of this tutotial.