What are the differences between ASP.Net MVC and ASP.Net Razor Pages?

1

What are the differences and limitations between ASP.Net MVC and ASP.Net Razor Pages?

I was curious, as apparently the Razor Pages use the MVC standard, but without the need to use a controller , I do not even know if this is really it, and if it is, it probably should not be just this.

Do you also have an advantage in using one or the other?

Is there any indication that ASP.Net Razor Pages can grow and become popular as ASP.Net MVC?

    
asked by anonymous 12.02.2018 / 21:27

1 answer

2

The first thing you need to understand is that Razor Pages is MVC, not a new technology, it totally depends on MVC. is a simpler way to use MVC by joining the VC into a single unit, because most of the times it is enough.

To tell you the truth, I see little sense in using MVC in the way they use it. If it were to deliver on multiple types of customers I would understand. It even occurs when using the WebAPI, and this is a case to continue in the normal MVC.

You can use MVC full where you need it and Razor Pages where it gives. It is not a binary choice. Mix if necessary.

What really changes is the organization of the code. You can continue to have a file with the code and a file with HTML, but it's all part of the view, it's like a code behind that you have in ASP.NET WebForms, you decide how to organize. There are methods to handle all requests in a standard way, you do not have to create a method for each request.

Overall I think that's it.

Why does MVC exist?

To modularize, give independence to each part of the application. So you can have several different views, several different models and several different controllers interacting in many ways.

The way the model is used never changes, and the vision even less, and there is not much to change, except in the case of WebAPI that the vision ceases to exist. Why complicate something when it's always the same?

What's the point of creating 3 layers if every change you make has to move the 3? What good is this design pattern if it creates complication? It serves precisely to make it interchangeable for responsibility. If the application does not need this much of the sales pitch is lost.

But today it was easy to sell something, just talk about it and people think that it solves everything.

Advantage

Whenever you stop using something you do not need, you're at an advantage. People use a lot without thinking because they are using it, they are just following, the recipe they learned.

Do you know why your mother is going to make the recipe you learned on television and it does not look good? Why did she follow the recipe. But you do not know how to do it. There are always factors that are not equal at all times that will do that. The environment is different, the brand of the product is different, the strength of the fire is different, the time it took to reach a dumb point. You have to know what to do, you can not follow the recipe pure and simple.

Of course the tool has to help, and now we have something that goes by the simplest path.

There are those who will say that it has other advantages, but in general it is snake oil for most cases, that is, it only cures a non-existent disease.

Adoption

Adoption is something difficult to predict, I would say yes because it is better for the vast majority of cases and because there is incentive to use it (it is the default application in Visual Studio for ASP.NET Core). I think they fixed some bugs.

ToobadIdidnotfindScottHanselmansayingitshouldbethedefaultchoiceandonlyadopttheMVCwhenRazorPagesdoesnotanswer.

Sinceweareinthefieldofopinion,Ihavealwaysfoundthecontrollerabitexaggeratedinmostcases.Ifthemodeliswelldone,besmart,andthepresentationwillknowwhattodowiththeslightlyheavierdata,that'sallyouneed.Ofcourseyoulosetheabilitytoexchangeparts.

Seemore

12.02.2018 / 22:37