find and solve ||
Please wait.....

ASP.NET Core Interview Questions and Answers

ASP. NET Core is an open-source and cross-platform and high performance platform that allows you to build modern, Internet-connected and cloud enabled applications that runs any types of operating system like Windows, Linux, and Mac and to develop modern cloud-based applications including IoT apps.You can deploy your code to cloud or on-premises.

Q1. What is the ASP.NET Core?

ASP.NET Core is an open-source, cross-platform and high performance platform,supporting Windows, MacOS and Linux, and can be used in device, cloud, and embedded/IoT scenarios. The first version of ASP.NET Core in 2016 released by Microsoft.

Cross-Platform:  The main advantage of ASP.NET Core is that it’s not dependent only  Windows operating system.You can develop Your application  ASP.NET Core apps on Linux or a Mac.

High Performance: core is the fastest web application frameworks.

Cross-platform: You can do your development on Linux, Windows and MacOS,can be ported to other OSes.

Command-line tools: All product scenarios can be exercised at the command-line.

Compatible: Core is compatible with .NET Framework, Xamarin and Mono, via the .NET Standard Library.

Q2. What are the features provided by ASP.NET Core?

 Some features are provided by the ASP.NET Core

  • Built-in supports for Dependency Injection.
  • Built-in supports for the logging framework and it can be extensible
  • Web application can run without IIS, Apache, and Nginx.
  •  CTS (Common Type System) standardizes the data types for all programming languages in .Net.
  • Common Language Runtime(CLR)  known as CLR is a run-time environment in .Net Framework.
  • Common Language Specification(CLS)
  • Multiple hosting ways are supported
  • Replace web.config by appsettings.json file
  • No need to Global.asax  use the services into startup class
  • Good response for asynchronous programming
  • Support WebSocket and SignalR
  • Provide protection against Cross-Site Request Forgery
  • Built in logging support.

Q3. What are the benefits of using ASP.NET Core

There are following advantages of ASP.NET Core over ASP.NET :

  • ASP.NET Core is faster compare to traditional ASP.NET
  •  Cross-platform, so it can be run on Windows, Linux, and Mac.
  • Multiple deployment options available
  • Provides Support for Popular JavaScript Frameworks.
  • There is no dependency on framework installation
  • ASP.NET Core can handle more request

Q4. What is Startup.cs file in ASP.NET Core?

Tthe entry point of the ASP.NET Core application is Startup.cs class and this class responsible for configuration related things like as given below

  • Configures the services which are required by the app.
  • Defines the app's request handling pipeline as a series of middleware components.
  public class Startup
        public Startup(IConfiguration configuration)
        {             Configuration = configuration;
        }         public IConfiguration Configuration { get; }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
        {             if (env.IsDevelopment())
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see                 app.UseHsts();
            }             app.UseHttpsRedirection();
            app.UseEndpoints(endpoints =>
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");

Database connection /configuration information in core.

Replace  web.config file by appsetting.json file so  we have to store  configuration information in appsetting.json.In the Asp.Net Core application we may not found the web.config file it's replace by "appsettings.json". So to configure the settings like database connections string,kyes,values,Mail settings or some other custom configuration settings we will use the "appsettings.json".We need to do is just inject the IConfiguration service through the constructor of the Startup.cs class.So Modify the Startup class which is present in the Startup.cs file.

for more details about appsettings.json

Q5. What is Dependency Injection?

 DI (Dependency Injection) is a Design Pattern that's used as a technique to achieve the Inversion of Control between the classes and their dependencies.DI allows to creation of dependent objects outside of a class and also provides those objects to a class through different ways.

There are 3 types of classes.

  1. Client Class: In client class depends on the service class
  2. Service Class: Provides service to the client class.
  3. Injector Class: The injector class injects the service class object into the client class.

For more details dependency injection

Q6. Middleware in ASP.NET Core

The Request handling pipeline is a sequence of middleware components where each component performs the operation on request and either call the next middleware component or terminate the request.When a middleware component terminates the request, it's called Terminal Middleware as It prevents next middleware from processing the request. You can add a middleware component to the pipeline by calling .Use... extension method as below.


So Middleware component is program that's build into an app's pipeline to handle the request and response. Each middleware component can decide whether to pass the request to next component and to perform any operation before or after next component in pipeline.

Q7.How Routing works in ASP.NET Core?

In ASP.NET Core routing is used to handle incoming HTTP/HTTPS requests for the application. Routing find matching executable endpoint for incoming http requests.When app starts these endpoints are registered. Matching process use values from incoming request url to process the requests. We can configure the routing in middleware pipeline of configure method in startup.cs class.

       app.UseEndpoints(endpoints =>
                name: "default",
                pattern: "{controller=Home}/{action=Index}/{id?}");
                //About Us
                    name: "AboutUs",
                    pattern: "about-us",
                    defaults: new { controller = "Home", action = "aboutUs" });               
                       name: "LogOut",
                       pattern: "log-out",
                       defaults: new { Controller = "Account", Action = "LogOffAsync" });
public void Configure(IApplicationBuilder app, IHostingEnvironment env){

   app.Use(async (context, next) =>{
      await context.Response.WriteAsync("First Middleware!");
      await next();
   app.Run(async (context) =>{
      await context.Response.WriteAsync("Second Middleware");

What is the difference between Run() and Use() methods in IApplicationBuilder?

View model :

Mahira  khanna

Mahira khanna

I have the skills you need for you company blog, website, or other content materials


Report Response