导航站点MathPath

发布于 2024-10-26 00:31:22 字数 1412 浏览 6 评论 0原文

我的应用程序有许多不同的用户,目前为他们设置了不同的母版页。这个想法是针对系统中某种类型的面包屑,即主页>详情>> ...

对此最好的方法是什么?我想我需要在 Web.sitemap (将有多个 SiteMapPaths)中定义每个用户可以拥有的单独路径(他们可以查看的所有页面),然后将站点地图控件添加到母版页并将它们链接到适当的 SiteMapPath,这听起来是解决这个问题的正确方法吗?

我在母版页中设置 SiteMapPath 时遇到问题。我使用了以下教程 http://geekswithblogs.net/azamsharp/archive/ 2006/08/16/88197.aspx 尝试使用该控件,但 SiteMapPath 控件未显示在母版页上当我登录时,您知道可能出现什么问题吗?

Web.sitemap:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

      <siteMapNode url="home.aspx" title=""  description="">
        <siteMapNode url="contacts.aspx" title=""  description="">   
    </siteMapNode>

</siteMap>

在主页上:

<asp:SiteMapPath ID="SiteMapPath1" runat="server">

          <RootNodeTemplate>

          <asp:HyperLink ID="HyperLink1" runat="server"
          Text='<%# Eval("title") %>' NavigateUrl='<%# Eval("url") %>' />

          </RootNodeTemplate>

          <NodeTemplate>
            <asp:HyperLink ID="HyperLink2" runat="server"
            Text='<%# Eval("title") %>' NavigateUrl='<%# Eval("url") %>' />
          </NodeTemplate>

          </asp:SiteMapPath>

谢谢

My application has a number of different users, currently there are different masterpages set up for them. The idea is for some type of breadcrumb in the system i.e. home > details > ...

What is the best approach for this? I think I will need to define the separate paths that each user can have (all the pages they can view) in the Web.sitemap (will have multiple SiteMapPaths) and then add the sitemap control to masterpage and link them to the appropriate SiteMapPath, does this sound like the right way to approach this?

I am having an issue with setting up the SiteMapPath within the masterpage. I used the following tutorial http://geekswithblogs.net/azamsharp/archive/2006/08/16/88197.aspx to try to use the control, but the SiteMapPath control is not displaying on the masterpage when I log in do you know what the problem might be?

Web.sitemap:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >

      <siteMapNode url="home.aspx" title=""  description="">
        <siteMapNode url="contacts.aspx" title=""  description="">   
    </siteMapNode>

</siteMap>

On the masterpage:

<asp:SiteMapPath ID="SiteMapPath1" runat="server">

          <RootNodeTemplate>

          <asp:HyperLink ID="HyperLink1" runat="server"
          Text='<%# Eval("title") %>' NavigateUrl='<%# Eval("url") %>' />

          </RootNodeTemplate>

          <NodeTemplate>
            <asp:HyperLink ID="HyperLink2" runat="server"
            Text='<%# Eval("title") %>' NavigateUrl='<%# Eval("url") %>' />
          </NodeTemplate>

          </asp:SiteMapPath>

Thank you

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

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

发布评论

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

评论(1

影子的影子 2024-11-02 00:31:22

如果您使用 FormsAuthentication 来控制用户对其可以导航的页面的授权,那么我建议也包括角色。然后在 sitemapprovider 中使用 securityTrimmingEnabled="ture"。这样您就不需要为每个用户提供单独的站点地图。

以下是其工作原理的基础知识:

您可能想要分享一些代码,让我们知道为什么您尝试的方法不起作用。

已编辑:1

您不需要内置角色提供程序即可实现此功能,但您确实需要向 UserPrincipal 添加角色。
如何做到这一点显示在此处
但是您需要编写代码,为每个真值返回角色作为字符串,即“admin”(如果数据库中的用户的 admin 为 true)。然后将这些角色添加到用户主体,如链接所示,它应该与第一个链接结合使用。

编辑:2
您不需要复杂的代码即可使 SiteMap 正常工作。您只需将其放在您的页面上,它就会根据您的 .sitemap 文件工作。此外,您还为 sitemapnode 设置了 title="" ,将其设置为某个值。

If you are using FormsAuthentication to control authorization of users for the pages they can navigate then I would suggest including Roles as well. Then use securityTrimmingEnabled="ture" in sitemapprovider. That way you won't need separate sitemaps for each user.

Here is basics of how it works:

And you might want to share some code for us to know why what you tried is not working.

Edited:1

You don't need built-in Roles provider for this to work but you do need to add roles to the UserPrincipal.
How to do that is shown here
But you will need to write code that returns roles as string for each true value i.e. "admin" if admin is true for the user in database. Then add those roles to user Principal as shown in the link and it should work in combination with the first link.

Edit:2
You don't need that complex code for SiteMap to work. You simply drop it on your page and it will work based on your .sitemap file. Also you have title="" for the sitemapnode, set that to some value.

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