I am confused about the architecture of Razor Pages in ASP.NET Core. Some sources claim that Razor Pages adhere to the MVC pattern, while others argue that they follow the MVVM pattern. Can someone clarify the architecture of Razor Pages and explain whether they should be considered as part of the MVC pattern, MVVM pattern, or something else entirely?
my opinion: I don't believe it follows the MVVM pattern because requests are made inside the page model (the ViewModel of MVVM) rather than inside the view. Therefore, it does not adhere to MVVM principles.
It appears to be an MVC structure with the C and M components within the page model.
some related links
It appears to be an MVC structure with the C and M components within the page model.
This is how I see Razor Pages, as I mentioned in one of the accepted answers you linked to. Each page has its own controller, implemented as a PageModel class, which represents an example of the Page Controller pattern. It is responsible for processing input from the request and preparing a model for the view (the .cshtml file). The only real difference between MVC and Razor Pages is that an MVC controller is typically scoped to an entity rather than a single page, although there is nothing to stop you scoping an MVC controller to an endpoint.