My problem is that I have a url as a string:
Then I have to make a Uri from it in order to pass as a parameter to the WebClient.But the Uri converts it to
http://server/foldername with space/picture.jpg.
And of course I cannot download the picture using this Uri.
Any idea how to resolve this?
Thank you in advance,
I tried this HtmlPage.Window.Navigate(new Uri("http://projectsilverlight.blogspot.com/search?q=deep%20zoom"), "_newWindow"); and it worked beautifully. A new window got invoked with the following URL: http://projectsilverlight.blogspot.com/search?q=deep%20zoom (retained the %20).
This worked fine as well:
String str = "http://projectsilverlight.blogspot.com/search?q=deep%20zoom";
HtmlPage.Window.Navigate(new Uri(str), "_newWindow");
Do you have a specific example to illustrate your problem?
Hope this helps!
Thank you for your reply.
I tried your example, it worked. One thing that I noticed is that you navigate to that Uri it doesn't matter if it replaces the spaces or not because the browser will replace it anyway.But I am using the Uri for downloading with Webclient.
In case of your example I have also seen that the Uri replaces the %20 with space..
I can show my case of course:
The server is a local Sharepoint server..
Uri u = new Uri(url);
I have tried setting the UriKind to Absolute but there was no difference in the result Uri.
You are absolutely right! The Uri object does convert %20 to a space.
As you mentioned, the reason it is working in the browser is because the browser converts a space to %20.
If there is no workaround for this, it would definitely be a showstopper. You should definitely post this in the 'Report a Bug' section if you do not get a solution soon.
Hello, this is by design. Uri's constructor will decode the uriString parameter. This behavior is consistent with desktop .NET. But this should not introduce any problems. I haven't tried SharePoint. But I tried a WCF REST service. I used this url with a WebClient:
It is replaced by:
http://localhost:25784/URIEncoding_Web/Service with space.svc/DoWork
But the runtime will point to the correct address, and I got the correct result.
I got your point with the consistency.
I am sure that this is not working for Sharepoint. There is no problem with calling the service from Sharepoint, that doesn't have spaces in it. The problem is when downloading something from a folder or list which has spaces.
Isn't there any setting for the Uri so I can keep the %20-s?
Or another solution would be for me if I could use the DownloadProgressChanged eventhandler of an Image. But it seemed I cannot. Why?