Basic .Net MVC questions Flashcards

1
Q

What is dependency Inhjection?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Why do we need DI?

A

To build loosely coupled sstems.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do we do model validation?

A

TBD

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is Razor?

A

Razor is a view engine which helps us to write a server side code and the C# code inside the view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are strongly types views?

A

They are razor views where we get Model intellisense. This avoids errors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a View Model?

A

View Model is a wrapper class around the multiple models that are required for the view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Explain kestrel web server ?

A

Kestrel is a default web server which comes with asp .Net core.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why kestrel web server when we have IIS ? .

A

ASP .Net Core is a cross-platform. But IIS is a windows specific. IIS wont work in non-WIndows platform

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Does Kestrel replace IIS?

A

No, we use Reverse Proxy server.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is Reverse Proxy server?

A

In Reverse Proxy server, The request from the user goes to the IIS or Apache whihc redirects it to the Kestrel.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is ASP.NET MVC Core ?

A

It is cross plafform and high performance framework to develop web applications.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Can you explain the difference between MVC core vs MVC 5 vs Webforms?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Explain MVC?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the importance of wwwroot?

A

It stores static files such as HTML CSS and JS.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Where do we store configuration in ASP.NET Core ?

A

appsettings.json. It is a simple file in JSON format. With name and value pair. configurations such as Connection strings are stored here.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How can we read configuration file in ASP.NET Core ?

A

We need to use IConfiguration.

CustomerCOntroller(IConfiguration config)
{
config[“connectonString”];
}

A readmade configuration will be DI to the controller.

For multi level, config[“level1:level2”]