Return different siteMapNodes for different roles
-
04-10-2019 - |
Pergunta
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?
Solução
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.
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>