I have created the same project on every project type of ASP.NET Core 5 (.NET 5 implementation). Obviously differentiating Blazor (Server or Web Assembly) with other Project types Like Razor pages, MVC, or Web API is simple, Also, The Web API is the odd man out.
My question is about Razor pages and MVC, I am a fan of MVC and never liked the page and code together, However Razor pages is different from WebForms as it follows MVVM, the two-way bindings.
But, I can't see any big advantage of using Razor pages over the MVC, in fact, I find MVC more maintainable, then why do Microsoft and many developers say Razor pages are more maintainable.
Also, there is nothing that Razor pages can't do and the MVC can. So, stating that Razor pages are just for small projects is a complete myth.
Question:-
As razor pages can do everything that MVC can, but in my perspective, MVC is more versatile, so why does Microsoft recommend Razor pages?

Sachin SinghPosted Jul 25, 2021, 6:33 PM
yes, I do agree with the points that you emphasized,
Each controller has a separate folder for views, but IDE does that for us anyway, if we add a view then it automatically goes to the right folder.
Yes, if we have to modify the view then we have to search for the right view, but then again it is not that tough or any maintenance nightmare.
second, the controller gets bloated with so many unrelated Actions, which violates the SRP and Open closed principle, this is again for those, who don't care for SOLID, I always keep the methods related to a particular controller, so it is also not that much valid point to end support for something.
I am afraid that Microsoft will soon end support for ControllerWithViews middleware as in their docs they have clearly mentioned that Razor pages are recommended way for Web UI projects and MVC is just for API.
Also, they have already ended the support for built-in Account Controller in the MVC template as Identity is now a Class Library project. This is a clear sign that ControllerWithViews will soon become obsolete.
I wanted that instead of saying that Razor is now the recommended approach, they would have stated that Razor is also a way to create Web UI.
what's your opinion on that? if Microsft ends support for ControllerWithViews middleware, then is it ok? for me, no it's not.
Rijwan AnsariPosted Jul 25, 2021, 5:36 PM
Let me share you my experience.
I had also similar question few months ago, however, I can share some advantages.
Earlier days, working with ASP.NET webforms was quite easy and flexible as each page has its own code behind. Very easy to understand and write code.
Then ASP.NET MVC came, we started moving to that. Initially, it was difficult, but after few months we were enjoying it. We are still loving it. ASP.NET MVC has several advantages over webforms.
Last 1 years, we are working on some projects with Asp.Net core Razor pages. Initially, we were frusted with it. But after few months again we started loving it again. It is like we are getting our webforms back (not exactly but similar structure).
Now with ASP.NET MVC,
Managing code like controlller in seperate folder with several actions and then views for each actions in another folder was making it difficult for long and complex project. Again models/VMs is in another folder.
Even we try to manage code and structure properly, it becomes complex with time and voulme of project. Each controller cantains several actions and views/partial vies. Even we try to seperate, but in long run, it becomes hard to work with, espacially for new developers.
These controllers will get complex day by day as well as views and models.
Once, you start using APS.NET core with Rozor pages then it will be easy for you to organize and structure in simple way.
Another advantage is single responsibility
If you see MVC, several controller actions which grows day by day, then seperate models and views.
But in Razor, each app page is self-contained with its own view and code organized together, which as a results, is less complex than the MVC.
It is more like modular web framework.
At last, I think this is all about adoption as well. Webforms, then ASP.NET MVC then again Razor pages.
Check this link as well
https://stackify.com/asp-net-razor-pages-vs-mvc/