Top 17 .NET Core Interview Questions

ASP.NET Core is the free & open-source framework developed by Microsoft. It is faster than ASP.NET. ASP.NET is cross-platform - supports Windows, Linux and Mac. ASP.NET Core works with both .NET Framework & .NET Core.


How does a .NET Core app start?

ASP.NET Core web application is basically a console application which starts executing from the entry point public static void Main() in Program class where we can create a host for the web application.

public class Program
    public static void Main(string[] args)

    public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>

Let's see below steps to understand how a .NET Core or ASP.NET Core application starts:

  • ASP.NET Core applications require a WebHost, while non-web based apps require a GenericHost.
  • This host basically works as an umbrella for the .NET Core apps.
  • It sets up lot of app resources when an app starts such as:
    • It starts Kestrel Web Server
    • Loads configurations from various configuration providers
    • Setup logging
    • Setup Dependency injection (DI)
  • This host is created by CreateWebHostBuilder method.
  • CreateDefaultBuilder method initializes host with default settings, but you can override or add additional settings using available extention methods such as:
    • ConfigureAppConfiguration
    • ConfigureLogging
    • UseEnvironment
    • UseSetting
    • UseContentRoot
    • UseIISIntegration
    • UseStartup
  • Once host is setup, kestrel server is running, your app is ready to serve the web requests.


What is Host Builder?

A host builder is an instance of either HostBuilder orWebHostBuilder class.

  • For http-based workloads, we use WebHostBuilder
  • For non-http-based workloads, we use HostBuilder

For ASP.NET Core (HTTP Based workloads)

  • an instance of IWebHostBuilder can be received from CreateWebHostBuilder method
  • we can use this instance to add/modify/remove features from .NET Core host instance


Difference between .NET Core SDK and .NET Core runtime?

.NET Core runtime

A runtime is the set of components that must be installed on a machine to run a framework-dependent app on the machine.

The .NET Core runtime includes the CoreCLR and the .NET Core base class library (earlier known as CoreFX).

For example:

  • .NET runtime = CoreCLR + .NET Core BCL
  • ASP.NET Core Runtime = CoreCLR + .NET Core BCL + ASP.NET Core framework libraries


The SDK includes everything you need to build and run .NET apps. It includes the following:

  • .NET Core run time (CoreCLR + .NET libraries )
  • .NET CLI
  • Language compiler
  • Other tooling


How would you host the .NET Core app on IIS?

To host an ASP.NET Core on IIS on Windows OS, you should download and install ASP.NET Core Hosting Bundle.

ASP.NET Core Hosting Bundle contains everything you need to run existing web/server apps. The bundle includes :

  • .NET Core runtime
  • ASP.NET Core runtime
  • ASP.NET Core IIS Module

ASP.NET Core IIS Module allows ASP.NET Core apps to run behind IIS.


Explain different ways to host a .NET Core Web Application?


IServiceProvider vs IServiceCollection


Difference between Configure and ConfigureServices methods. Which one is optional?


How to set the hosting environment in ASP.NET Core?


In-process hosting vs Out process hosting in .NET Core?


Explain usage of UseStaticFiles() and UseDefaultFiles() methods in .NET Core?


app.Use() vs app.Run() vs app.Map() vs vs app.MapWhen()


Difference between HTTP Handler and HTTP Modules?


How would you implement the HTTP Module in .NET Core?


How would you implement the HTTP Handler in .NET Core?


Name a few built-in HTTP Modules?

Here are a few built-in HTTP modules: - FormsAuthentication - SessionStateModules - HttpCacheModule


What is Configuration Provider in .NET Core?


Difference between AddScoped(), AddTransient() and AddSingleton() methods?