0

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.

mlst
  • 2,688
  • 7
  • 27
  • 57
  • I could suggest you create a mapping page and role mapping. so you will have the info the user has certain roles and those roles can access the page and in the page table, you can store the page URL as well. so you can directly get this info by calling database query – Vivek Nuna Oct 09 '21 at 11:49
  • 1
    Here's a high-vote [answer](https://stackoverflow.com/a/46182527) which may help you, but I agree with @viveknuna, it seems that you need to prepare a view-control page that can set all the pages(including urls) and can control the pages to assign to different roles. So it's better to have a role management page and a user management page to manage the users and roles, and then you can make each user to see specific pages as all these information is stored in the database. – Tiny Wang Oct 11 '21 at 07:15

0 Answers0