Top 20 .NET Core Interview Questions

In this post, we will discuss the top 20 .NET Core interview questions. Prepare for your next .NET Core interview with our list of top 20 questions.

1- What is .NET Core?

.NET Core is an open-source .NET platform that allows you to build cross-platform applications, so your apps can run on Windows, Linux, and macOS. This (.NET Core) was usually used for developing web applications and backend services, but with the latest version of .NET Core, you can develop desktop applications as well.

Read: .NET Core 3 for Windows Desktop


2- What are some characteristics of .NET Core?

  • Cross-platform: .NET Core runs on Windows, macOS, and Linux operating systems. There are different runtime for each operating system that executes the code and generates the same output.
  • CLI Tools: Command-Line support to build and run applications
  • Open Source: .NET Core is open source and cross-platform and is maintained by Microsoft and the .NET community on GitHub.
  • Deployment Flexibility: Ability to deploy on more than one server like IIS, Docker, Apache, etc.
  • Compatibility: Compatible with .NET Framework and Mono APIs by using .NET Standard specification.
  • Multiple Language Support: You can use C#, F#, and Visual Basic programming languages to develop .NET Core applications.


3- What is the difference between .NET Core and .NET Framework?

.NET Framework.NET Core
Not open sourceIs open source. Built and maintained by microsoft and .net community on GitHub.
Applications built using this framework can run only on Windows OS.Application built using .NET Core are cross-platform i.e. they can run on Windows, Linux or MacOS.
All the libraries of .Net Framework are packaged and shipped together..Net Core is shipped as a collection of Nugget packages.


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


5- What is Dependency Injection in .NET Core? What is its advantage?

Dependency Injection is a design methodology where rather than the caller creating the instance it’s injected by some framework or some other mechanism. By using Dependency Injection we are implementing the Inversion of Control (IOC) concept.

Read: .NET Core, Dependency Injection and Inversion of Control (IoC)

The advantage of Dependency Injection is it helps us to achieve Decoupled Architecture, where you can change in one place and changes are reflected in many places.


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


7- What is middleware?

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.


8- What happened to Startup.cs file in .NET Core 6 and above?

In .NET Core 6, the Startup.cs file has been moved into the Program.cs file. Or we can say that the contents of the Startup.cs of .NET 5 have been moved to Program.cs in .NET 6.

Read: Startup.cs Missing in .Net 6 and Above


9- What are Exception Filters?

Exceptions that are thrown but are not handled will lead to the execution of exception filters. IExceptionFilter interface is implemented by the exception filters.


10- What are Razor Pages?

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


12- 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


13- What is Kestrel?

  1. Kestrel is a lightweight web server used for hosting
  2. Kestrel is cross-platform and can be used with other web servers like IIS, Nginx, and Apache.
  3. Kestrel is open-source like .NET Core.


14- Explain Response Caching in ASP.NET Core.

Caching improves the performance of an application by reducing the number of calls to the actual data source. Response caching is best suited for data that changes infrequently. Caching makes a copy of data and stores it instead of generating data from the original source.
Response caching headers control the response caching. ResponseCache attribute sets these caching headers with additional properties.


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

Read: Content Negotiation In Asp.net Core Web API


16- What is Routing in ASP.NET Core?

Routing in ASP.NET Core MVC is the mechanism through which incoming requests are mapped to controllers and their actions. This is achieved by adding Routing middleware to the pipeline and using IRouteBuilder to map URL pattern (template) to a controller and action.


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


18- What is the difference between SDK and Runtime in .NET Core?

  • SDK is the stuff that is required to develop a .NET Core application such as the CLI and the compiler.
  • The runtime is the “virtual machine” that hosts/runs the application and abstracts all the interaction with the base operating system.


19- What is Metapackage?

Metapackage is automatically added to the application by the .NET Core framework. The name of the package provided by ASP.NET Core is Microsoft.AspNetCore.App. It helps developers to do faster development as they don’t require to include the individual ASP.NET Core packages.


20- What is .NET Standard?

.NET Standard is not a framework. It defines a set of APIs that the platforms must implement to be compliant with the .NET standard. .NET Framework, .NET Core, and Mono for Xamarin all follow the .NET Standard rules.

Share on facebook
Share on twitter
Share on linkedin

Related articles