I would like to create an ASP.NET Core 2.2 project using Razor Pages.
My objective is to create a project that contains two categories of Razor Page:
- Standard category: this category contains all Razor Pages that will be shared across multiple project
- Custom category: this category contains all Razor Pages that are relative to the project.
Up to here is all ok, I create two subfolder inside "Pages" directory: Standard folder, Custom folder. I populate standard and custom folders with all razor page I need in every project, where all the razor pages contained inside Standard folderz are the same in all my project.
For example
Project A:
- /Pages
- /Standard
- /SectionA
- PageA
- PageB
- /SectionA
- /Custom
- /SectionE
- PageD
- /SectionE
- /Standard
Project B:
- /Pages
- /Standard
- /SectionA
- PageA
- PageB
- /SectionA
- /Custom
- /SectionP
- PageK
- /SectionP
- /Standard
Project C:
- /Pages
- /Standard
- /SectionA
- PageA
- PageB
- /SectionA
- /Custom
- /SectionV
- PageJ
- /SectionV
- /Standard
Here born my problem: I would implement the possibility, inside every project, to extend a standard razor page, maybe to rewrite some endpoint (for example I want to change the behaviour of "onGet" method) or create a new one (like "onGetMyCustomGet").
I know that the simpliest solution is to change the code inside the standard razor page, but I want to avoid this because standard pages can be replaced with new versions. So, Standard Pages must be project-indipendent and open to extension.
My idea is to create a "fake" Razor page, inside "/Custom" category that extend the standard razor PageModel and override all methods I need to reimplement.
The problem is: how can I return the standard razor page cshtml instead the fakeRazorPage cshtml? Is it possible?
Here you will find a sample project https://github.com/Blackleones/RazorPageResearch feel free to send pull request if you want collaborate.
Other ideas are accepted if there are not solutions