Skip to content

Modifying SiteMapNode.RouteValues in action method does not change URL when security trimming is enabled #272

@rahulbpatel

Description

@rahulbpatel

As per the article How to Make MvcSiteMapProvider Remember a User’s Position
(http://www.shiningtreasures.com/post/2013/09/02/how-to-make-mvcsitemapprovider-remember-a-user-position), this code example does not seem to work when security trimming is enabled:

public ActionResult Edit(int id)
{
    var node = SiteMaps.Current.FindSiteMapNodeFromKey("Product_Edit");
    if (node != null)
    {
        node.RouteValues["id"] = id;
        var parent = node.ParentNode;
        if (parent != null)
        {
            parent.RouteValues["id"] = id;
        }
    }

    // Implementation omitted
}

Here's what looks like is happening:

  1. SiteMaps.Current.FindSiteMapNodeFromKey causes AuthorizeAttributeAclModule.FindRoutesForNode method to be executed
  2. AuthorizeAttributeAclModule.FindRoutesForNode is calling RequestCacheableSiteMapNode.Url and causing the URL to be cached for the request
  3. The action method will execute and modify the RouteValues but it has no effect because
  4. RequestCacheableSiteMapNode.get_URL calls GetCachedOrMemberValue with the storeInCache argument set to true

I'm not sure exactly would be the most sensible way to fix this issue. Perhaps if the RouteValues property is modified that the request cache is cleared?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions