sitemap url problems

Jan 6, 2010 at 11:45 PM

The SiteMap adds the nodes fine, but when i click the previous node (and it is dynamic) i get an error.

when debuging i checked the prev nodes its Url is "controller/action" but it has to be "controller/action/id"
if it is not a dinamic node (action doesn't take any parammeters) every thing works fine

the SiteMap.CurrentNode.Url is fine but it seems SiteMap.CurrentNode.ParentNode.Url cannot be even changed programmaticaly and after the CurrentNode becomes a parent it loses the Id value

this is a part of the sitemap

<mvcSiteMapNode title="title1" controller="controller1" action="List" isDynamic="true" dynamicParameters="*" key="HospitalListKey">
<mvcSiteMapNode title="title2" controller="controller2" action="Details" isDynamic="true" dynamicParameters="id">

we use Windor Castle i our app. i think it could be because of it.

is it because of windsor or im doing something wrong?

Jan 7, 2010 at 9:01 AM

Are you trying something similar to this?

       public ActionResult Details(string id)
            if (string.IsNullOrEmpty(id))
                id = "ASP.NET MVC 1.0 Quickly";
            // Get category
            string category = products.Where(p => p.Key == id).First().Value;
            // Set sitemap node title
            SiteMap.CurrentNode.Title = string.Format("{0}", id);
            // Set parent node title
            SiteMap.CurrentNode.ParentNode.Title = string.Format("{0}", category);
            SiteMap.CurrentNode.ParentNode.Url = Url.Action("List", new { id = category }).Replace("..", "~/Products");
            // Return view
            return View();
Jan 7, 2010 at 2:53 PM
Edited Jan 7, 2010 at 6:06 PM

yes i tried to do like that but the Url doesn't save the Id.

in my case the Url has to be "controller/action/Id", but i save only "controller/action"

what if my Action Method take an Int as a parameter. what then? and i always have an error:

"The parameters dictionary contains a null entry for parameter 'id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult Details(Int32)' in 'WebUI.Controllers.HospitalController'. To make a parameter optional its type should be either a reference type or a Nullable type.

Parameter name: parameters"

all my Actions take an int type as a parameter, how can i solve this problem??

also when i check i debug mode the Attributes of the ParentNode it doesn't have an Id

Jan 7, 2010 at 6:05 PM

Can you post some reproducing code?