Basic .Net MVC questions Flashcards
What is dependency Inhjection?
DI is a process of injecting the dependent objects(classes) to a class instead of class creating the dependent object.
For example, in controller class, we inject the AppDBContext. If we create the DBContext in the controller class, then it will be tightly coupled. If we create a new AppDBContext later, then we have to change it in all controllers.
Why do we need DI?
To build loosely coupled sstems.
How do we do model validation?
TBD
What is Razor?
Razor is a view engine which helps us to write a server side code and the C# code inside the view.
What are strongly types views?
They are razor views where we get Model intellisense. This avoids errors.
What is a View Model?
View Model is a wrapper class around the multiple models that are required for the view.
Explain kestrel web server ?
Kestrel is a default web server which comes with asp .Net core.
Why kestrel web server when we have IIS ? .
ASP .Net Core is a cross-platform. But IIS is a windows specific. IIS wont work in non-WIndows platform
Does Kestrel replace IIS?
No, we use Reverse Proxy server.
What is Reverse Proxy server?
In Reverse Proxy server, The request from the user goes to the IIS or Apache whihc redirects it to the Kestrel.
What is ASP.NET MVC Core ?
It is cross plafform and high performance framework to develop web applications.
Can you explain the difference between MVC core vs MVC 5 vs Webforms?
There are many differences:
a. MVC core is a cross-platform.
b. MVC core has built0in DI.
c. MVC code has appsettings.json
d. MC Core has high performace.
e. static files are grouped under wwwroot.
Explain MVC?
In MVC, our projects are divided into three layers:
a. Model: The data for the view.
b. View: the UI.
c. THe coontroller whihc binds the Model and the view.
What is the importance of wwwroot?
It stores static files such as HTML CSS and JS.
Where do we store configuration in ASP.NET Core ?
appsettings.json. It is a simple file in JSON format. With name and value pair. configurations such as Connection strings are stored here.