ASP.NET MVC Core Interview Questions
- By Shiv Prasad Koirala in ASP.NET
- Aug 5th, 2021
- 2064
- 0
Defining ASP.NET Interview Scope preparation
When you talk about asp.net interviews the range of questions can be very narrow or it can be very wide. So do ensure you have proper preparation strategy at place. Remember ASP.NET has three versions of framework. So we had ASP.NET Webforms which came in 2003, followed by the ASP.NET MVC , then we had ASP.NET MVC Core.
Now if you are junior / fresher I would say stick to MVC Core and say you have just worked with MVC core , so that you do not get the questions of Webforms and MVC.
But if you are senior you do not have too many choices you will need to prepare through right from Webforms to MVC Core.
So I have created three categories of ASP.NET Interview questions on which Webfrom , MVC 5 and other is MVC Core.
This eBook covered only ASP.NET MVC Core questions.
What is ASP.NET MVC Core ?
ASP.NET MVC Core is an open source, cross platform framework to develop web applications. When you develop web applications using ASP.NET Core it can run on windows, Linux and mac.
Can you explain the difference between MVC core vs MVC 5 vs Webforms?
| Webforms (2003) | ASP.NET MVC 5 (2009) | ASP.NET MVC Core (2017) |
Cross platform | No | No | Yes |
Performance | Worst state cycle.due and to page view life | Less than ASP.NET Core | Best of all the versions. |
Simplification | Quite complicated | Mediumly complicates | Very simplified. |
Cloud ready | Not meant for cloud. | Not complete | Yes |
HTML control | Very less | Good control Razore view due to | Good control due to Razor view. |
Configuration | Web.config | Web.config | Appsetting.json |
Dependency Injection | Need third party | Need third party | Built in |
Self-hosting | No | No | Yes (Kestrel) |
Static content | No | No such folder | wwwroot |
Nuget Managed | Not Fully | Not fully | Completely Nuget managed |
Drag and Drop Rad | Full marks | Need to code | Need to code. |
Development | Only windows | Only windows | You can develop on mac , linux using VS Code. |
Can you explain MVC Architecture?
Where do we store configuration in ASP.NET Core ?
Configuration data is stored in a json file called as Appsettings.json .
How can we read configuration file in ASP.NET Core ?
To read configuration from appsettings.json you need to use "IConfiguration" interface
What is dependency injection?
Dependency injection is practice of providing dependent objects for a class from outside rather than the class creating it. So, in simple words the object creation process is isolated from the caller. This helps to create a proper decoupled system.
Why do we need dependency injection ?
By using DI classes are decoupled from each other so you make changes at one place its reflected all over the places.
How to implement dependency injection ?
To implement DI we need to add the service in "ConfigureServices" method which is in Startup.cs file.
Explain the concept of middleware ?
Middleware helps to add pre-processing logic before the request is sent to the controller.
How to implement middleware in MVC Core ?
Middlewares are added in "Configure" method of Startup.cs file. Explain the importance of Startup.cs file in ASP.NET Core ? Startup.cs file helps to configure Dependency injection and Middle wares.
Explain the various way of doing DI in MVC ?
There are three ways of doing DI :- Scoped , Transient and Singleton Singleton :- Instantiates once in an application life time
Scoped :- Instantiates once per request made to server Transient :- Instantiates every singletime service is injected.
What are the various ways of doing session management in ASP.Net Core ?
* Session variables
* Tempdata
* ViewData / ViewBag
What is the difference between ConfigureServices and Configure method ?
In ConfigureServices we add the objects to be dependency injected while in Configure method we specify middlewares
Explain Razor pages ?
Razor is a view engine in which you can write both C# and HTML code. C# code is rendered at the server side.
How can we pass model data to the view ?
You can pass by using viewdata or using strongly typed views.
What is a strongly typed view ?
Strongly typed views are Razor views where we get intellisense for the model used in the view.
Explain the concept of viewModel ?
View Model represents the data to be displayed on the view.
Explain kestrel web server ?
Kestrel is an open source default web server used by ASP.NET core application. Kestrel ships with ASP.NET Core setup and works as in-process web server to handle web request. Kestrel is cross platform it works on Linux , windows and Mac.
Every request of ASP.NET core goes through kestrel first.
Why kestrel web server when we have IIS ?
ASP.NET core is meant to run cross platform. So, IIS as default server will not work , because IIS works only on Windows. Web server like NGINX , Apache and so on have their own way to running the application startup and ASP.NET core can not satisfy each one of them. So kestrel acts like a in- process web server take a request send to MVC core application , get response and sends it back to the main web server.
Explain concept of reverse proxy ?
Reverse proxy is a concept where the server acts like a mediator. Kestrel works on reverse proxy concept it takes the request from the main web server like IIS / Apache and forwards its to MVC application and vice-versa.
Pending Questions
- How to implement JWT token security in ASP.NET ? Whats the importance of Filters ?
- Generic Host vs WebHost ?
- How can we manage to add and switch environment specific appsetting file?
- what is the difference between IApplicationBuilder.Use() and IApplicationBuilder.Run()? what is the difference between htmlhelper and taghelper?
- How to create custom taghelper?
- How to create our own custom htmlhelper? How to enable Session in Asp.net core
- Ways of implementing versioning in Asp.net core Api
- .csproj file, and it's importance in .net core. comparison of .csproj file with previous version of .net Questions on Authentication and Authorisation with Azure Ad.
- Questions on Publishing the application, many times we get error after publishing. Eg 502.5 , 500.30 etc etc
- What is the difference between creating .net std library and .net core library? what is use of UseRouting and UseEndpoints in Startup Configure method
- How to store ServiceCollection in different location other than ConfigureServices method What is ViewComponent? and can we inject Dependency in ViewComponent?
- how to use in-memory cache in asp.net core reading appsetting.json values in controller
- how to store object in session other than string and int in asp.net core. how to create CUSTOM MIDDLEWARE in ASP.NET CORE
- use of launchsetting.json in ASP.NET Core
- how to configure runtime compilation of views while development. :- AddRazorRuntimeCompilation(); Health checks
- ASYNCACTIONFILTER IN ASP.NET CORE MVC
- How to Secure asp.net core with oAuth2.0 and what is oAuth middle ware
- Authentication in asp.net core web api and OWIN
- Explain factory pattern using built - in DI in asp.net core What are filters in ASP.NET Core?
- .csproj file, and it's importance in .net core. comparison of .csproj file with previous version of .net Ways of implementing versioning in Asp.net core Api
- What is IOption in ASP.NET core
Shiv Prasad Koirala
Visit us @ www.questpond.com or call us at 022-66752917... read more