Basics Flashcards
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?
Now there are like 10 to 12 differences and if we try say all of them during interviews its not going to work. Always remember let the interviewer speak more and you as a candidate should speak to the point. I have listed below all 12 points but would recommend to start with the first 4 points which are highlighted.
![](https://s3.amazonaws.com/brainscape-prod/system/cm/352/402/156/a_image_thumb.jpg?1627653172)
Can you explain MVC Architecture?
MVC is an architecture pattern where we
divide project in to three layers.
The first layer is the view which has things
like Color, UI positioning, CSS, input
controls, buttons and so on.
Second layer is Model which is a simple
class which has business validations.
Controller binds the model and the view.
So the first hit comes to the controller, it
loads the model and binds the model data to
the view.
![](https://s3.amazonaws.com/brainscape-prod/system/cm/352/404/076/a_image_thumb.jpg?1627654076)
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?
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
Explain the various way of doing DI in MVC?
This is an easy topic to understand but very difficult to explain to interviewer in simple words. So, I
would suggest to go through the below explanation, understand it and create your simple one liner.
![](https://s3.amazonaws.com/brainscape-prod/system/cm/352/405/260/a_image_thumb.jpg?1627654638)
There are three ways of doing DI:
Scoped, Transient and Singleton.
- *Transient**: - Creates new instances, every single time service is injected.
- *Scoped**: - Creates new instances, once per request made to server.
- *Singleton**: - Instantiates one global object for all requests coming to server from any user.
The below image shows the same visually. In transient for every dependency injection new instance
will be injected. For example, in the below image for “obj” and “obj1” fresh new instances will be
injected for every request.
In case of scoped for every request same instance will be injected for every dependency injection. So
“obj” and “obj1” will have same instance injected.
In case of singleton one big global instance created. For all request , for all Dependency injection same
instance will be injected.
What are the various ways of doing session management in ASP.Net Core ?
- Session variables
- Tempdata
- ViewData / ViewBag
ConfigureServices vs 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.