Uri Query Property Inaccessible when Uri is Relative June, 2009
Why, why, why? Is it not possible that someone would want to parse a relative uri that has a querystring? M$, why do you impose these needless limits? Ok, so lets say we have the following UriTemplate:
/books/?language={language}
And you want to pick this uri apart and grab the querystring portion. You can load it into a Uri as relative but the Query and Segments properties will not be accessible and you will get the following exception: "This operation is not supported for a relative URI." There is a simple workaround but I really don't think we should have to do this. Basically you pass in a dummy base uri along with your relative one and this does the trick:
Uri myUri = new Uri(new Uri("dummy:"), "/books/?language={language}"); System.Diagnostics.Debug.Print(myUri.Query);
If you want to vote on changing this, click here for the Microsoft Connect feedback page.