Skip to main content

ASP.NET Core Interview Questions

Q. What is .NET Core?

Ans: .NET Core is a newer version of .NET, which is cross-platform, supporting Windows, macOS and Linux, and can be used in device, cloud, and embedded/IoT scenarios.

The following characteristics best define .NET Core:

  • Flexible deployment: Can be included in your app or installed side-by-side user- or machine-wide.
  • Cross-platform: Runs on Windows, macOS and Linux; can be ported to other OSes. The supported Operating Systems (OS), CPUs and application scenarios will grow over time, provided by Microsoft, other companies, and individuals.
  • Command-line tools: All product scenarios can be exercised at the command-line.
  • Compatible: .NET Core is compatible with .NET Framework, Xamarin and Mono, via the .NET Standard Library.

Q. How is it different from existing .NET framework?

Ans: Read my post Difference between .NET Core and .NET Framework

Q. What are .NET Platform Standards?

Ans: Read my post about .NET Platform Standards

Q. What is ASP.NET Core?

Ans: ASP.NET Core 1.0 is the next version of ASP.NET. It is open source and cross-platform framework (supports for Windows, Mac and Linux) suitable for building cloud based internet connected applications like web apps, IoT apps and mobile apps. ASP.NET Core apps can run on .NET Core or on the full .NET Framework.

Q. What are the newly introduced functionalities in ASP.NET Core?

Ans: Read my post about Quick summary of what’s changed in ASP.NET Core

Q. What is ASP.NET Core Middleware and How it is different from HttpModule?

Ans: Read my post about How ASP.NET Core 1.0 Middleware is different from HttpModule

Q. What are the various Json files in ASP.NET Core?

Ans: Read my post about Various JSON files in ASP.NET Core

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

Ans: In ASP.NET, Global.asax (though optional) acts as the entry point for your application. Startup.cs, it is entry point for application itself. The Startup class configures the request pipeline that handles all requests made to the application. Read this read this excellent post The Startup.cs File in ASP.NET Core 1.0 – What Does It Do? to know more about startup.cs.

Q.What ConfigureServices() method does in Startup.cs?

Ans: This method is optional. It is the place to add services required by the application. For example, if you wish to use Entity Framework in your application then you can add in this method.

public void ConfigureServices(IServiceCollection services)  
{
    services.Configure<AppSettings>(Configuration.GetSubKey("AppSettings"));
    services.AddEntityFramework()
            .AddSqlServer()
            .AddDbContext<SchoolContext>();
    // Add MVC services to the services container.
    services.AddMvc();
}

Q.What Configure() method does in Startup.cs?

Ans: The Configure method is used to specify how the ASP.NET application will respond to HTTP requests. The request pipeline is configured by adding middleware components to an IApplicationBuilder instance that is provided by dependency injection. There are some built-in middlewares for error handling, authentication, routing, session and diagnostic purpose. Highlighted lines in below code, are built-in Middleware with ASP.NET Core 1.0.

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
    loggerFactory.AddConsole(Configuration.GetSection("Logging"));
    loggerFactory.AddDebug();
 
    app.UseApplicationInsightsRequestTelemetry();
 
    if (env.IsDevelopment())
    {
        app.UseBrowserLink();
        app.UseDeveloperExceptionPage();
    }
    else
    {
        app.UseExceptionHandler("/Home/Error");
 
        // For more details on creating database during deployment see http://go.microsoft.com/fwlink/?LinkID=615859
        try
        {
            using (var serviceScope = app.ApplicationServices.GetRequiredService<IServiceScopeFactory>()
                .CreateScope())
            {
                serviceScope.ServiceProvider.GetService<ApplicationDbContext>()
                        .Database.Migrate();
            }
        }
        catch { }
    }
 
    app.UseIISPlatformHandler(options => options.AuthenticationDescriptions.Clear());
    app.UseStaticFiles();
    app.UseIdentity();
 
    // To configure external authentication please see http://go.microsoft.com/fwlink/?LinkID=532715
 
    app.UseMvc(routes =>
    {
        routes.MapRoute(
            name: "default",
            template: "{controller=Home}/{action=Index}/{id?}");
    });
}

Q.What is the difference between app.Use vs app.Run while adding middlwares?

Ans: Read app.Use vs app.Run in ASP.NET Core middleware.

Q.What are different ASP.NET Core diagnostic middlwares and how to do error handling?

Ans: Read Various ASP.NET Core Diagnostics Middleware.

Q.How to handle 404 error in ASP.NET Core 1.0?

Ans: Read How to handle 404 error in ASP.NET Core 1.0

Q.What is launchsetting.json in ASP.NET Core?

Ans: Read Launchsetting.json in ASP.NET Core

Q.What are the differences between ASP.NET MVC 5 and ASP.NET MVC Core 1.0?

Ans: Read Difference between ASP.NET MVC 5 and ASP.NET MVC Core 1.0.

Note: This page will be updated on timely basis. So keep visiting for new set of questions. Meanwhile please check others post to dive into ASP.NET Core.