为不同的角色返回不同的siteMapNode

发布于 2024-09-02 17:25:03 字数 208 浏览 4 评论 0原文

我正在使用自己的 SiteMapProvider,它只是继承并稍微重写了 System.Web.XmlSiteMapProvider

我想为客户和经理返回不同的 siteMapNode 。或者可能相同但具有不同的 Title 属性。

是否可以?如果是,我该怎么做?

I'm using my own SiteMapProvider which is just inherited and little bit rewritten System.Web.XmlSiteMapProvider.

I want to return different siteMapNode for clients and for managers. Or maybe the same but with different Title property.

Is it possible? If yes, how can I do that?

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

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

发布评论

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

评论(1

幸福%小乖 2024-09-09 17:25:03

这是 Scott Gu 博客中的一篇文章,可以帮助您。本文中的示例使用 Windows 身份验证,但它也应该适用于表单身份验证。

http://weblogs.asp.net/scottgu/pages/Recipe_3A00_-Implementing-Role_2D00_Based-Security-with-ASP.NET-2.0-using-Windows-Authentication-and-SQL-Server.aspx< /a>

如果您想为不同的角色实现不同的头衔,那么这里是如何实现这一点的示例。您需要做的就是创建两个指向相同 url 的节点。 a=1 和 a=2 作为 url 上的查询字符串变量的原因是为了确保 url 是唯一的。如果 url 不唯一,asp.net 会抱怨,除非您可以覆盖该功能...

    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
        <siteMapNode url="default.aspx" title="Home">
            <siteMapNode url="page1.aspx?a=1" title="Client Title" roles="Client" />
            <siteMapNode url="page1.aspx?a=2" title="Manager Title" roles="Manager" />
        </siteMapNode> 
    </siteMap>

Here is an article from Scott Gu's blog that can help you out. The example in the article is using windows authentication but it should also work for forms authentication as well.

http://weblogs.asp.net/scottgu/pages/Recipe_3A00_-Implementing-Role_2D00_Based-Security-with-ASP.NET-2.0-using-Windows-Authentication-and-SQL-Server.aspx

If you want to implement different titles for different roles then here is an example of how that can be done. All you need to do is create two nodes pointing to the same url. The reasons for a=1 and a=2 as querystring vars on the url is to ensure that the url is unique. If the url is not unique, asp.net will complain, unless you can override that functionality...

    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
        <siteMapNode url="default.aspx" title="Home">
            <siteMapNode url="page1.aspx?a=1" title="Client Title" roles="Client" />
            <siteMapNode url="page1.aspx?a=2" title="Manager Title" roles="Manager" />
        </siteMapNode> 
    </siteMap>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文