0

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

最好的方法是什么?我想我需要在 Web.sitemap(将有多个 SiteMapPaths)中定义每个用户可以拥有的单独路径(他们可以查看的所有页面),然后将站点地图控件添加到 masterpage 并将它们链接到适当的 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>

谢谢

4

1 回答 1

0

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.

于 2011-03-25T20:21:07.980 回答