Silverlight 4 Beta Networking. Part 1 - WebClient and XML

Play Silverlight 4 Beta Networking. Part 1 - WebClient and XML

The Discussion

  • User profile image



    Thanks for the exmple on how to use WebClient and asynchronous operations from the client. I do however have a question re: this.  The web client seems like a great tool by which to use to get media from a site and allow a user to download. however, with the save dialog box doesn't allow itself to be invoked from a non-user initiated event, which contradicts the async approach. 


    Any recomendations on how to work around this without having to prompt a user multiple times?

  • User profile image

    Hi BigDubb,


    Are you saying that you can't;

    1. Prompt the user for a file to save to.
    2. Capture the file stream they choose.
    3. Begin async download via WebClient.
    4. On download complete, write downloaded contents to FileStream from step (2) above.
    5. Dispose dialog.
    I seem to remember having problems trying to write to this kind of FileStream from a background thread but I'm not sure if I've seen a particular issue doing 1-5 above ( although I haven't gone off and explicitly written the code to test it yet ).

  • User profile image
    Mike Greenway

    Mike's Videos are always very helpful for people like myself - self taught and still learning.

    • He always starts at the beginning - assuming I know little.
    • He remembers what it is like to "not know" and answers the question I have before I ask them
    • the pace is just right and the level of detail is right on
    • Best of all - he uses USABLE examples

     There are many good programmers but few good teachers


    Thank you Mr. Taulty


    Mike Greenway

  • User profile image

    Thank you Mr. Greenway - very kind & glad you found these useful Smiley



  • User profile image

    A quick note on these videos - they have become a little less relevant with the release of the Silverlight RC.


    Be wary of changes that happened between the beta and the RC. Not every video will be affected but some definitely are.

  • User profile image
    Jon Bushby

    Real shame webClient still has no support for credentials. Just tried RC and it's still not there. Sad

  • User profile image



    Not sure what you mean - WebClient does have support for credentials. Off the top of my head - if you're on the Browser stack then it'll on use default credentials but if you're on the Client stack it can either use default/prompt or take supplied credentials based on the UseDefaultCredentials property.


    Is that not what you're seeing?



  • User profile image

    Hi Jon,
    Hope you are doing well.
    I am developing a solution in WP7 with CRM.
    As you know that to access any data in CRM you need to provide user credentials.
    So I provide it in the following way.

    WebClient Download = new WebClient ();

    NetworkCredential creds = new NetworkCredential("username", "password", "domainname" );  

    Download.Credentials = creds;



    Download.DownloadStringCompleted += new DownloadStringCompletedEventHandler 



    Download.DownloadStringAsync(new Uri http://servername:5555/organizationname/XRMServices/2011/OrganizationData.svc/LeadSet?$select=FirstName


    private void Download_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)


    string Any = e.Result.ToString();



     if (e.Error == null

  • User profile image

    can we create silverlight 4.0 pie chart using XML data file?

Add Your 2 Cents