Question

Currently, I have a Controller with an Index() action method that needs authorization:

public partial class CustomerController : BaseDocumentStoreController
{
    [Authorize(Roles = AccountController.Administrator)]
    public virtual ViewResult Index()
    {
        ...
    }

    ...
}

With this in place, the respective node in the Mvc.sitemap won't show in the breadcrumbs:

<mvcSiteMapNode     title="Customer"         controller="Customer" action="Index"
                    resourceKey="Customers"  clickable="true" >

    <mvcSiteMapNode title="Customer Add"     controller="Customer" action="Add"
                    resourceKey="Add"  />
    <mvcSiteMapNode title="Customer Create"  controller="Customer" action="Create"
                    resourceKey="Add" />
    <mvcSiteMapNode title="Customer Edit"    controller="Customer" action="Edit"
                    resourceKey="Edit" />
    <mvcSiteMapNode title="Customer Update"  controller="Customer" action="Update"
                    resourceKey="Edit" />
    <mvcSiteMapNode title="Customer Delete"  controller="Customer" action="Delete"
                    resourceKey="Delete" />
    <mvcSiteMapNode title="Customer Details" controller="Customer" action="Details"
                    resourceKey="Details" />
    <mvcSiteMapNode title="Customer Search"  controller="Customer" action="Search"
                    resourceKey="Search" />

</mvcSiteMapNode>

What I want is to show this node anyway...

Let's say the user is not authenticated. So I want the breadcrumbs to show this:

Home > Customers > Add

Currently it only shows:

Add

If the user clicks the Customers node he'll be redirected to the login view... OK, that's fine!

I tried to implement my own SiteMapVisibilityProvider following these steps:

public class SiteMapVisibilityProvider : ISiteMapNodeVisibilityProvider
{
   ...
}

While debugging I could only see the nodes bellow the Index node, that is, in my current case, only the Add node showed up. The node that represents the Index action method didn't show up in the debugging session.

Is there any way of achieving what I want?

Was it helpful?

Solution

The problem most likely lies in the DefaultAclModule, which hides all nodes inaccessible to the current user. If you don't want that functionality it can be disabled by setting securitytrimming to false, in the sitemap provider in web.config.

You could also change the functionality by implementing a custom AclModule.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top