Marc Cals
Marc Cals

Reputation: 2989

Web.sitemap display links in function of role

I have one Web page , that can be only accessed if user has one of two allowed roles "Politician" or "Worker". Dependending from which user role is accessed the title of the web in the navigation sitemap has to be different.

In our web.config this page is configured to be accessed with the two roles "Politician" or "Worker", and in web.sitemap I have the next code.

<siteMapNode url="DoTask.aspx?Validator=Worker" title="TitleForRole" roles="Worker" />
<siteMapNode url="DoTask.aspx?Validator=Politician" title="TitleFolRoleB"  roles="Politician" />

The problem is with that code is despite of user has only one of the roles in the sitemap appear the two links.

Is there a way to make only visible the link user has the role in sitemap?

One solution is create a page for one of the roles that redirect to DoTask.aspx and change sitemap

<siteMapNode url="DoTask.aspx?Validator=Worker" title="TitleForRole" roles="Worker" />
<siteMapNode url="RedirectToDoTask.aspx" title="TitleFolRoleB" roles="Politician" />

But I think this is not elegant solution, I would like to avoid to create another page.

Thanks for your help.

Upvotes: 1

Views: 300

Answers (1)

Related Questions