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 SiteMa开发者_JAVA百科pPath, 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
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.
精彩评论