none
Download image stream using WebClient class.

    Question

  • 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

    Tuesday, May 08, 2012 3:18 AM

Answers

  • 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.

     

    Tuesday, May 08, 2012 11:22 PM
  • I think the client access policy file should be on the server from which I retrieve the photos, and not on my side.

    Yes, it is on the server-side.

    You need to provide it on the server-side.If not , you cannot access the server.

    Sunday, May 13, 2012 10:35 PM

All replies