Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

It seems the Client Object Model is stripping out the "query" part of a URL stored inside the NavigationNode elements. I am wondering if this is a bug or perhaps I am doing something wrong?

Consider the following example. Site navigation is configured with a single item under the global navigation called Affordability and a URL that contains ?FilterField1=ContentType&FilterValue1=Affordability at the end of URL for the All Items view:

var root = "https://server/sites/site/";
var ctx = new ClientContext(root);
var web = ctx.Web;
var nav = web.Navigation;
ctx.Load(nav);
ctx.ExecuteQuery();
var bar = nav.TopNavigationBar;
ctx.Load(bar);
ctx.ExecuteQuery();

// use the TopNavigationBar collection
Console.Write(bar[0].Title + "=" + bar[0].Url);
// outputs "Affordability=/sites/sites/Lists/List/AllItems.aspx"

It seems to strip off the actual filtering part of the URL. It is still present in the Navigation settings, and clicking the link in the Web UI works just fine. I understand I could create views for all the different filtering criteria - that isn't really what I am looking for though. I am curious to see if this is a bug in the Client Object Model (maybe I somehow have an old version?) or perhaps I doing something wrong?

share|improve this question

1 Answer 1

up vote 1 down vote accepted

Thanks to Oleg's post: http://www.thedotnotcorner.com/2012/12/12/add-a-query-string-parameter-to-spnavigationnode/

It seems that in a site with the Publishing feature enabled, the query string is stored in a separate property: UrlQueryString.

So to access the full Url+QueryString you would need: bar[0].Url+bar[0].Properties["UrlQueryString"]

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.