samedi 9 octobre 2021

Is there a way to get urls of all PageModel classes in ASP.NET Core Razor Pages via reflection?

I am creating an ASP.NET Core 5 Razor Pages app and I want to add one page that would show all accessible pages (their urls) for the currently logged user. Each user has different level of authorization permissions and thus I would check [Authorization] attribute and its Policy property for that. On the other hand, the admin user has access to all pages and thus it should see all urls/pages available in the app.

So far I was able to use reflection to get all PageModel classes with their [Authorization] attribute, but now I am wondering is there a way to get url for each of those PageModels? Note that I am doing all this at the application runtime so routing infrastructure should be up and running when I do this.





Aucun commentaire:

Enregistrer un commentaire