How to ignore URL parameters

Jun 22, 2011 at 10:54 AM

First of all I would like to say thank you for the great project, it's very useful.

I use MVC3 and MvcSiteMapProvider version 3.0.0.0.

In some part of the project we need to create dynamic site map and we use dynamicNodeProvider like this:

 

<mvcSiteMapNode title="Assets" controller="AssetState" action="Index" showMainMenu="true" showSubMenu="true" customTemplate="~/Views/AlertCount.cshtml">
     <mvcSiteMapNode title="Locations" dynamicNodeProvider="SiteMapNodeProviders.AssetSiteMapNodeProvider" />
</mvcSiteMapNode>

 

In our site map node provider class we add nodes like this:

 

DynamicNode locationNode = new DynamicNode
            {
                Title = title,
                Key = id,
                ParentKey = parentKey,
                Action = action,
                Controller = controller,
                RouteValues = new Dictionary<string, object> { { "locationId", location.Id } }
            };

 

Site map works with following URL: http://localhost/LocationState/Details?locationId=7a1f6ca1-bf5c-40fc-8038-8d1281668aba

But in some case we need to add additional parameter like http://localhost/LocationState/Details?locationId=7a1f6ca1-bf5c-40fc-8038-8d1281668aba&forceTableView=True

Working solution is to add additional DynamicNode with forceTableView into the RouteValues:

 

DynamicNode locationNode = new DynamicNode
            {
                Title = title,
                Key = id,
                ParentKey = parentKey,
                Action = action,
                Controller = controller,
                RouteValues = new Dictionary<string, object> { { "locationId", location.Id }, { "forceTableView", true } }
            };
DynamicNode locationNode = new DynamicNode
            {
                Title = title,
                Key = id,
                ParentKey = parentKey,
                Action = action,
                Controller = controller,
                RouteValues = new Dictionary<string, object> { { "locationId", location.Id }, { "forceTableView", false } }
            };

 

Is there a way to ignore the URL parameter forceTableView or list of parameters like "forceTableView, anotherToIgnore"?

Thanks,
Vangi

Coordinator
Jun 29, 2011 at 12:36 PM

Can't you just omit the parameter when it's supposed to be false?

Apr 19, 2012 at 2:48 PM

I leave it like this until now, but now I need to fix it. Now I need to ignore another parameter with more values:

splitCase=riga, splitCase=trumb, splitCase=fatal, etc.

This is just a dynamic parameter which is processed in the page, but not important for the SiteMapProvider.