MVC Sitemap accessing controller action

Oct 19, 2011 at 11:42 PM

Hi Friends,

I am just testing mvc site map. I have a controller Account and a action Admin which is accessible by Administrator roles only.

In my site map file I have said

<mvcSiteMapNode title="Admin" controller="Account" action="Admin" key="AccountAdmin" roles="Administrator" />

Now when the page is render it doesnt show the link in site map, but i can access the Admin controller by typing the url in the browser.

I can control it by using Authorize on that action, but that means, I have to specify it twice, once in site map file and then in the codes.

Is there any way, where I should be able to write it once (just in site map).

Help will be appreciated.

Oct 20, 2011 at 3:20 PM
Edited Oct 20, 2011 at 3:22 PM

For me, specifying the roles only in the Authorize attribute works. I'm using MVC 3.

Place this in your sitemap:

<mvcSiteMapNode title="Admin" controller="Account" action="Admin" />

and this in your controller/action:




Nov 2, 2011 at 11:18 AM

Did you find a soltion virik0009? Having the same problem..

I´m setting the Authorize in the controller only, but the menu node is always hidden after logging in. The user does have the right role :)

Nov 22, 2011 at 7:33 AM

It is either roles="..." or using the authorize attribute.