I am new to net5 framework and have some questions regarding the structure of the project. When we create a new project it will only create the razor pages. I am learning that we can achieve things with these razor pages. Meanwhile, I have looked into some open source net5 projects on GitHub and see that they are also using MVC. So, my question is why do we need MVC then? If everything is achieved using razor pages then what is the need for MVC? If we need MVC then should we use razor pages with them too? I have done the identity work with razor pages using scaffolding. What would happen now if I add MVC to my project. How will I manage the routes and page redirection from razor pages to MVC and vice versa? Please help me with this so I can clear my concepts on this. I will be really thankful to those who explain the scenario to me. Thanks
CodePudding user response:
First, .NET 5 is out of support. You should target .NET 6 instead.
Razor Pages represents a simpler way to generate HTML on the server compared to MVC. It is recommended for all new web applications that rely on server-side HTML generation going forward. MVC is still available for existing apps. It is also probably easier to migrate older MVC 5 (.NET Framework) apps to ASP.NET Core MVC when porting to .NET Core.
Razor Pages is built on top of the MVC framework and depends on a lot of the features of MVC such as
https://docs.microsoft.com/en-us/aspnet/core/razor-pages/?view=aspnetcore-6.0&tabs=visual-studio