I have a WP7 project where I am using the below code. It normally works ok, but I am getting a strange result with some particular strings being passed through.
Service = "3q%23L3t41tGfXQDTaZMbn%23w%3D%3D?f"
NavigationService.Navigate(new Uri("/Details.xaml?service=" + Service, UriKind.Relative));
Next Page:
NavigationContext.QueryString.TryGetValue("service", out Service1);
Service1 now = 3q#L3t41tGfXQDTaZMbn#w==?f
Why has the string changed?
The string hasn’t changed, but you’re looking at it in two different ways.
The way to encode
3q#L3t41tGfXQDTaZMbn#w==?ffor as URI content is as3q%23L3t41tGfXQDTaZMbn%23w%3D%3D?f. (Actually, it’s3q%23L3t41tGfXQDTaZMbn%23w%3D%3D%3Ffbut you get away with the?near the end not being properly escaped to%3Fin this context).Your means of writing the string, expects to receive it escaped.
Your means of reading the string, returns it unescaped.
Things are working pretty much perfectly, really.
When you need to write the string again, then just escape it again: