Answered by:
Download image stream using WebClient class.

-
text/html 5/8/2012 3:18:40 AM Bogdan Ioan Gabor 0
Hi,
I have a list of URLs which points me to some images (JPGs).
For every URL from the list, I would like to use image's stream.
I used WebClient class in order do that but it seems like now, it doesn't work anymore, and I'm pretty sure is due to the fact that the clientaccesspolicy.xml (I get a SecurityException) file is missing from the target server (don't know why it worked in the first place).
1.Is there any way to bypass the clientaccesspolicy.xml?
2.If not (I'm pretty sure this is the answer), is anything I can do, on my side, in order to make this working?
3.Is there any other way to take the stream of those images using the URL list?
My code:
// FOREACH LOOP
WebClient webClient = new WebClient(); webClient.OpenReadCompleted += (s, ev) => { if (ev.Error != null) { // handle the error response } else { // handle the ev.Result (which is a Stream) } }; webClient.OpenReadAsync(new Uri(url)));
// END FOREACH LOOP
Question
Answers
-
text/html 5/8/2012 11:22:11 PM Otomii Lu 0
Hi,
There is some useful information below:
Silverlight policy file - the Silverlight policy file that can be used by the WebClient and HTTP classes in the System.Net namespace and also by the sockets classes in the System.Net.Sockets namespace. This policy file has a different format than the Flash policy file.
You can download cross-domain content using WebClient APIs from the client perspective. But the server that is serving cross-domain must have a client access policy that allows cross-domain access. For more information, see Network Security Access Restrictions in Silverlight.
So you need a clientaccesspolicy.xml and you cannot bypass it.
I suggest you to provide a clientaccesspolicy and use WebClient to query for it.
-
text/html 5/13/2012 10:35:00 PM Otomii Lu 0
All replies
-
text/html 5/8/2012 1:53:42 PM JessieJakubowski 0
-
text/html 5/8/2012 11:22:11 PM Otomii Lu 0
Hi,
There is some useful information below:
Silverlight policy file - the Silverlight policy file that can be used by the WebClient and HTTP classes in the System.Net namespace and also by the sockets classes in the System.Net.Sockets namespace. This policy file has a different format than the Flash policy file.
You can download cross-domain content using WebClient APIs from the client perspective. But the server that is serving cross-domain must have a client access policy that allows cross-domain access. For more information, see Network Security Access Restrictions in Silverlight.
So you need a clientaccesspolicy.xml and you cannot bypass it.
I suggest you to provide a clientaccesspolicy and use WebClient to query for it.
-
text/html 5/12/2012 5:31:27 AM Bogdan Ioan Gabor 0
-
text/html 5/13/2012 10:35:00 PM Otomii Lu 0
-
text/html 8/17/2013 6:53:10 PM George Birbilis 0