Net Core Interview Questions & Answers

Are you a .Net professional? If yes, then go ahead and train yourself in Net Core, which has faster cycles and can be upgraded easily. Wisdomjobs helps you to learn all the features of the Net Core technology, provides you with information of the certification courses to learn Net Core and also gives a list of different job availabilities, where you can put your skills to use. As a Net Core user you can work on open source and cross platforms in order to improve the performance with language constructs. You will be able to find economical solutions for the next generation mobile, IoT and also cloud technologies. Browse wisdomjobs to search for the Net Core based jobs and prepare yourself, to build a bright future. Following are some of the Net Core job interview questions and answers to help you to do well in your job interview.

Asp.net Core1.0 is the next version of Asp.net which is 5.0. 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 has made itself independent of System.Web.dll and is heavily based on the modular NuGet packages.

It is use to build up the HTTP pipeline via webHostBuilder.Use() chaining it all together with WebHostBuilder.Build() by using the builder pattern. It is available within the Microsoft.AspNet.Hosting namespace.The purpose of the Build method is to build the required services and a Microsoft.AspNetCore.Hosting.IWebHost which hosts a web application.

UseIISIntegration configures the port and base path the server should listen on when running behind AspNetCoreModule. The app will also be configured to capture startup errors. WebHostBuilder uses the UseIISIntegration for hosting in IIS and IIS Express.

This method belongs to the Microsoft.AspNetCore.Builder namespace of USEDeveloperExceptionPage Extensions static class. The purpose of this function is to capture synchronous and asynchronous System.Exception instances from the pipeline and generates HTML error responses. It returns a reference to the app after the operation is completed.We use the UseDeveloperException() extension method to render the exception during the development mode.

The AddSingleton method, adds a singleton service of the type specified in TService with an implementation type specified in TImplementation to the specified Microsoft.Extensions.DependencyInjection.IServiceCollection. It returns a reference to this instance after the operation has completed.

Services can be registered with the container in several ways.In this case we are using Singleton Service by using the AddSingleton<IService, Service>() method.Singleton lifetime services are created the first time they are requested and then every subsequent request will use the same instance. If the application requires singleton behavior, allowing the services container to manage the service's lifetime is recommended instead of implementing the singleton design pattern and managing the object's lifetime in the class.

The encoding used to transfer the entity to the user. It is set to Chunked indicating that Chunked transfer encoding data transfer mechanism of the Hypertext Transfer Protocol (HTTP) is initiated in which data is sent in a series of "chunks".

It is the custom header. It contains the base64-encoded path to the source file on disk and is used to link a page's generated output back to that source file. It's only generated for localhost requests.

If you get an error "The term 'Scaffold-DbContext' is not recognized as the name of a cmdlet" , simply Close the Visual Studio and open again.

This creates .cs files related with all database tables into Models folder of your project. This also creates a database context (in this case the name will be TrainingDatabaseContext.cs as the database name is TrainingDatabase).

ASP.NET Core is a brand new cross-platform web framework built with .NET Core framework.

It is not an update to existing ASP.NET framework. It is a complete rewrite of the ASP.NET framework. It was built from scratch in the effort to make a modular, scalable, super fast, configurable, cross-platform and easily extended web framework.

ASP.NET Core (on Linux!) itself can handle over 2 000 000 – 2 Million requests per second for plaintext request/response scenarios. ASP.NET Core MVC can handle over 1 million requests per second! Compared to Node.js, which can handle about 400 000 requests per second, this is an amazing effort.

It works with both .NET Core and .NET Framework.

ASP.NET Core is much cleaner and easier to work with. You only need to write 20~30 lines of code and you have the web server ready to run. It also works smoothly with your file system, so can just copy and paste files to your project folder. And no, you don’t need to reference these files from a .csproj file.

Main characterestics of ASP.NET Core:

DI Container which is quite simple and built-in. You can extend it with other popular DI containers

Built-in and extensible structured logging. You can redirect output to as many sources as you want (file, Azure, AWS, console)

Extensible strongly typed configuration, which can also be used to reload at run-time

Dependency Injection comes as a part of ASP.NET Core Framework and everything is built around it. When you want to use some tool and its services, you usually add the NuGet package and you use one of its extension methods to add the package to the ASP.NET Core’s DI container. You can extend the current DI with a container of your choice (AutoFac, StructureMap, CastleWindsor etc).

Another crucial part of ASP.NET Core Framework is Configuration. Also, it is part of Dependency Injection. Use it anywhere in your code with an option to reload on changes of configuration values from sources (appsettings.json, environment variables, command line arguments, etc.). It is also easy to override, extend and customize the Configuration. No more extensive configurations in web.config, the preferred way now is appsettings.json in combination with a mix of Environment variables and cmd-line args.

Logging is built-in and you get access to structured logs from the ASP.NET Core host itself to your application. With tools like Serilog, you can extend your logging easily and save your logs to file, Azure, Amazon or any other output provider. You can configure verbosity and log levels via configuration (appsettings.json by default), and you can configure log levels by different categories.

CreateDefaultBuilder extension method will create a default configuration which will look first into appsettings.json files then will look for Environment variables and at the end, it will use command line arguments.

This part will also set up default logger sources (debug and console) and load the settings for logging from appsettings.json.

After the CreateDefaultBuilder finishes, then Startup class is executed. First, the constructor code is executed. After that, services are added to DI container via AddServices method that lives in Startup class. After that, an order of middleware that will handle every incoming request is set up.

.csproj file is now used as a place where we manage the NuGet packages for your application.

File explorer and project explorer are now in sync. For .NET Core projects, you can easily drop a file from file explorer into a project or delete it from the file system and it will be gone from the project. No more source files in a .csproj file.

You can now edit the .csproj file directly without unloading the project.

Razor Pages is a new feature of ASP.NET Core that makes coding page-focused scenarios easier and more productive.

With Razor Pages, you have this one Razor file (.cshtml), and the code for a single page lives inside of that file, and that file also represents the URL structure of the app (more about this later). Therefore, you got everything inside of one file, and it just works.

However, you CAN separate your code to the code behind file with .cshtml.cs extension. You would usually have your view model and handlers (like action methods in MVC) in that file and handle the logic there. Of course, you could also have your view model moved to separate place.

Since Razor Pages is part of the MVC stack, you can use anything that comes with MVC inside of our Razor Pages.

launchsettings.json: can define project specific settings associated with each profile Visual Studio is configured to launch the application, including any environment variables that should be used. You can define framework for your project for compliation and debugging for specific profiles.

bundleconfig.json: can define the configuration for bundling and minification for the project.

project.json: storing all project level configuration settings

bower.json: Bower is a package manager for the web. Bower manages components that contain HTML, CSS, JavaScript, fonts or even image files. Bower installs the right versions of the packages you need and their dependencies

The differences between the two can be summarized in these three points:

NuGet-based: .NET Core is distributed as a set of NuGet packages that allow app-local deployments. In contrast, the .NET Framework is always installed in a system-wide location. This difference doesn’t matter so much for class libraries; but it matters for applications as those are expected to deploy the closure of their dependencies. But we expect this model to change how quickly class library authors can take advantage of new functionality. Since the applications can simply deploy a new version (as opposed to having to wait until a given .NET Framework version is widely adopted), there is less of a penalty for component authors to take advantage of the latest features.

Well layered: .NET Core was specifically designed to be layered. The goal was to create a .NET stack that can accommodate a wide variety of capabilities and system constraints without forcing customers to recompile their binaries and/or produce new assets. This means that we had to remove certain APIs because they tied lower level components to higher level components. In those cases, we provide alternatives, often in the form of extension methods.

Free of problematic tech: .NET Core doesn’t include certain technologies we decided to discontinue because we found them to be problematic, for instance AppDomain and sandboxing. If the scenario still makes sense for .NET Core, our plan is to have replacements. For example, AssemblyLoadContext replaces AppDomains for loading and isolating assemblies.

.NET Framework is the "full" or "traditional" flavor of .NET that's distributed with Windows. Use this when you are building a desktop Windows app or working with ASP.NET 4.5/4.6.

.NET Core is cross-platform .NET that can run on Windows, Mac, and Linux. Use this when you want to build applications that can run on any platform, including ASP.NET Core (cross-platform web applications).

Xamarin (Mono) is used for building mobile apps that can run on iOS, Android, or Windows Phone devices.

.NET Core and the .NET Framework have (for the most part) a subset-superset relationship. .NET Core is named "Core" since it contains the core features from the .NET Framework, for both the runtime and framework libraries. For example, .NET Core and the .NET Framework share the GC, the JIT and types such as String and List