1

I have created a site which has some roles. and each user can have some roles. every role has permission to some pages. I want to build menus dynamically depending on user roles so every user can see his available pages in his menu. I want to know that what is the best way to do this? using an XML to describe this menus hierarchy and specify each role available menus or there is better way to do this?

John Farrell
  • 24,673
  • 10
  • 77
  • 110
JGC
  • 12,737
  • 9
  • 35
  • 57
  • Previously answered question. [http://stackoverflow.com/questions/3623818/creating-menus-dynamically-in-web-application/10225825][1] [1]: http://stackoverflow.com/questions/3623818/creating-menus-dynamically-in-web-application/10225825 – Moiz Apr 19 '12 at 10:20

3 Answers3

1

Rather than reinventing the wheel, I'd strongly suggest using Telerik's Extensions for ASP.NET MVC.

It includes a powerful Menu extension and has good programmability. I've used the .Visible() method along with IPrincipal.IsInRole() to determine which menus are available and when.

What's better is that it's free and open source! There's a paid-for version with support, but community and forum support seems to be quite good enough.

Steve Morgan
  • 12,978
  • 2
  • 40
  • 49
1

we have a mysql database that has the roles and objects and a decision is made at run time based on the logon user as to who gets to see what. There is also a decision made on individual pieces or controls on the page. There can also be tests on the pages themselves to make sure it's not just a menu that's hiding a page.

johnny
  • 19,272
  • 52
  • 157
  • 259
0

I used the MVC sitemap project in combination with a "Security Trimming" link helper ( "Security aware" action link? ) for this sort of thing before. Pretty easy.

Community
  • 1
  • 1
John Farrell
  • 24,673
  • 10
  • 77
  • 110