基于用户的不同 asp:menu

发布于 2024-10-31 21:18:36 字数 422 浏览 1 评论 0原文

我有一个 Oracle 数据库,用于存储本地 Intranet 的菜单和用户数据。

该数据包括哪些用户有权访问哪些页面。

最初,我创建了一个扩展 StaticSiteMapProvider 类的类,但是当它进入测试环境时,我发现它是为整个站点缓存的(而不是基于用户)。在各种论坛上在线阅读后,建议我应该从 SiteMapProvider 继承,因为这将使我能够在用户基础上拥有 SiteMapProvider 和 ASP:MENU 项目的单独实例,但这仍然没有解决问题。

目前我有一个用户控件,它限制 asp:menu,并使用我的自定义站点地图提供程序作为其数据源。

谁能建议我如何在数据库授权的驱动下以用户为基础显示菜单?

此外,整个菜单仍然应该向所有用户显示,只有在单击菜单节点后,他们才会发现他们是否有权访问该页面/节点。

谢谢

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 found 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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

同尘 2024-11-07 21:18:36

您可以使用站点地图上的角色来定义将显示的菜单。

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

我一直都在从未离去 2024-11-07 21:18:36

这里有两件事。如果您有静态节点集合,然后想要根据用户可访问性显示/隐藏它们,那么您应该覆盖 IsAccessibleToUser
方法来判断给定节点是否适用于当前用户(可从给定的 HttpContext 访问)。

如果您的节点集合/层次结构根据每个用户进行更改,请尝试覆盖 BuildSiteMap 为当前用户加载不同的节点。但是,我有点怀疑 StaticSiteMapProvider 在这种情况下是否是正确的基类。可能您需要从 SiteMapProvider 进行覆盖。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文