开发者

Different asp:menu on a user basis

开发者 https://www.devze.com 2023-02-24 04:56 出处:网络
I have a oracle database which stores menu and user data, for a local Intranet. The data includes which usesr have access to which pages.

I have a oracle database which stores menu and user data, for a local Intranet.

The data includes which usesr have access to which pages.

Originally I created a class which extened the StaticSiteMapProvider class, however when this went in to the testing environment, i f开发者_JAVA百科ound that this was cached for the whole site (and not on a user basis). After reading up on line on various forums, it was suggested that I should inherit from SiteMapProvider as this would enable me to have a seperated instance of thet SiteMapProvider and ASP:MENU item on a user basis, however this still hasn't solved the problem.

Currently I have a user control, which conrains the asp:menu, and uses my custom site map provider as its data source.

Could anyone suggest how I can display the menu on a user basis, driven from database authorisation?

Also the whole menu should still appear to all users, it only after thy click on a menu node that they will find out whether they have access to that page/node.

Thanks


You can make use of Roles on the SiteMap to define what menu will appear.


There are two things here. If you have static collection of nodes and then you want to show/hide them based on user accessibility then you should override IsAccessibleToUser method to tell if the given node if applicable for the current user (accessible from given HttpContext).

In case, your nodes collection/hierarchy changes per user basis then try overriding BuildSiteMap to load different nodes for current user. However, I am a bit doubtful if StaticSiteMapProvider is the correct base class in this case. Probably you need to override from SiteMapProvider.

0

精彩评论

暂无评论...
验证码 换一张
取 消