Base solution for your next web application
Open Closed

Approach to define Menu at the top from code or database and give permission to UserRoles #8209


User avatar
0
olmy90 created

Hi, what is the recommended approach to define Menu at the top from code or database and give permission to UserRoles?

I have different UserRoles which should get access to only a subset of menu items Currently the menu is hardcoded - but I need to give certain UserRoles permissions

  1. To open / see / read a page
  2. To insert data
  3. To update data
  4. To delete data

Is there any documentation for an implementation - I think also other dev have same requierments, THANKS


2 Answer(s)
  • User Avatar
    0
    musa.demir created

    If what you need is use ASP.Net Zero's default menu system you can check https://docs.aspnetzero.com/en/aspnet-core-mvc/latest/Features-Mvc-Core-Main-Menu-Layout


    Or, If what you need is store your menu items somewhere else or change its filter method, you can override UserNavigationManager. aspnetboilerplate/UserNavigationManager.cs

    Create a new class inherited from IUserNavigationManager and replace it with the existing one.

       Configuration.ReplaceService<IUserNavigationManager, MyUserNavigationManager>();
    
  • User Avatar
    0
    olmy90 created

    Thanks!