Online Training for Asp.net MVC Web Designing Development, MS SQL, Digital Marketing
Asp.net Core Interview Questions

Asp.net Core Interview Questions Answers

This post is about ASP.NET Core Interview Questions.These questions are good enough to assess a candidate if he/she has working knowledge about Asp.Net Core, These are kind of guidelines for core ASP.NET Core concepts and some experience in real-time application development using Asp.net Core.
If you are job seeker or going for ASP.NET Core interviews, this will help you to get ready for potential questions be asked during interview.
What is .NET Core?
Asp.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.
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
Main characterestics of ASP.NET Core?
  • There is no web.config, We now use appsettings.json file to store configuration information
  • There is no Global.asax, We have Startup.cs, to setup new Middleware and services for DI Container.
  • Dependency injection is heavily used in asp.net core framework, We can extend it with other popular DI containers
  • We have built-in and extensible structured logging in Asp.Net Core, also can use third party logging utility
  • fully async pipeline. It is easily configured via middleware
  • Razor page, specially designed for small size application, supports cross platform deployment
  • Provide protection against CSRF (Cross-Site Request Forgery)
  • Support WebSocket and SignalR
  • Command-line supports to create, build, run an application
Where to keep configuration information in asp.net core.
Now there is no web.config file, in Asp.net core we have to store configuration information in asppsettings.json file, which is plain text file, keep information as key-value pair in json format .
{
  "Logging": {
    "IncludeScopes": false,
    "LogLevel": {
      //"Default": "Warning"
      "Default": "Debug",
      "System": "Information",
      "Microsoft": "Information"
    }
  },

  "DbConnectionConfig": {
    "DatabaseName": "databaseName",
    "UserName": "username",
    "Password": "password",
    "ServerName": "IP-Address"
  }
}
What is Middleware in ASP.NET Core?
Middleware is software injected into the application pipeline to handle request and responses. Now we can manipulate http request and response which was not possible with earlier Asp.net Framework, Middleware are just like chained to each other and form as a pipeline. We can change the order in configuration
What is the startup class in ASP.NET core?
Startup class is the entry point of any ASP.NET Core application, This class contains the application configuration rated details, it has two main method ConfigureServices() and Configure()
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();
services.AddMvc().AddRazorOptions(opt =>
            {
                opt.PageViewLocationFormats.Add("/Pages/shared/{0}.cshtml");
            });
        }

     public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {

        }
    }
       
What are advantages of ASP.NET Core compare to ASP.NET?
Here are the key advantages of using Asp.Net Core
  • It supports cross-platform application building, so it can be run on Windows, Linux and Mac.
  • Now no framework installation required, because all the required dependencies are packaged with asp.net core application
  • Asp.Net Core has in-built logging capabilities
  • ASP.NET Core can handle request more efficiently than the ASP.NET
What is Configure method of startup class, what does it do?
It defines the HTTP pipeline, how the application will respond to request. We can change the sequence of middleware configuration, it accepts IApplicationBuilder as a parameter and two optional parameters: IHostingEnvironment and ILoggerFactory.
Using this method, we can configure built-in middleware such as authentication, error handling and also any custom middleware or third-party middleware.
Difference between IApplicationBuilder.Use() and IApplicationBuilder.Run()?
Both methods are used to add middleware delegate to the application request pipeline.
Use method may call the next middleware in the pipeline.
Run method never calls the subsequent ore next middleware, After IApplicationBuilder.Run method, system stops adding middleware in pipeline
Explain routing in ASP.NET Core?
Routing is the functionality that map incoming request to the route handler. There are two type of routing supported by ASP.NET Core
  • Conventional routing
  • Attribute routing
How to enable Session in ASP.NET Core?
The middleware for the session is provided by Microsoft.AspNetCore.Session. To use the session in ASP.NET Core application we need to add the middleware in pipeline
public class Startup
 {
     public void ConfigureServices(IServiceCollection services)
     {  
         services.AddSession();
         services.AddMvc();
     }

     public void Configure(IApplicationBuilder app, IHostingEnvironment env)
     {
        app.UseSession();
     }
 }
What are the different JSON files available in ASP.NET Core?
  • appsettings.json
  • bundleconfig.json
  • global.json
  • npm-shrinkwrap.json
  • launchsettings.json
  • bower.json
  • package.json
How automatic model binding in Razor pages works?
When we create a razor page, it provides the option to have model binging or not, in model binding there is a model created with the razor page, the model is inherited from : PageModel
we need to use [BindProperty] attribute to bind any property to model Here is an example
public class ContactModel : PageModel
 {
     [BindProperty]
     public string StudentName { get; set; }
 }
Hope these above questions answer will help you to get ready for interview, if you have more time, please check our free Asp.net Core tutorial with Code Sample

Group Training