Question about setting MvcSiteMapNode's Url

Sep 12, 2009 at 3:44 AM

in MvcSiteMap 1.0 Sample, ProductsController's Details action contains the code:

SiteMap.CurrentNode.ParentNode.Title = string.Format("{0}", category);
SiteMap.CurrentNode.ParentNode.Url = Url.Action("List", new { id = category }).Replace("..", "~/Products");

it seems not work while setting ParentNode's Url's value, the value of ParentNode's Url is not changed.

In the class MvcSiteMapNode, i find the code:

        public override string Url
        {
            get
            {
                RequestContext ctx;
                if (HttpContext.Current.Handler is MvcHandler)
                    ctx = ((MvcHandler)HttpContext.Current.Handler).RequestContext;
                else
                    ctx = new RequestContext(new HttpContextWrapper(HttpContext.Current), new RouteData());

                return new UrlHelper(ctx).Action(Action, Controller, new RouteValueDictionary(RouteValues));
            }
            set
            {
                base.Url = value;
            }
        }

the setter of Url can not change Url's value.

Actually,  in MvcSiteMap 1.0 Sample, when request action '/Products/Details/Intel%20Core%20i7', its category is 'Electronics', but the link of the site map node ' Electronics' is '/Products/List', not '/Products/List/Electronics'.

 

would u like give me any suggestion?

 

thanks

Coordinator
Sep 14, 2009 at 7:28 AM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.