Entries:
Comments:
Posts:

Loading User Information from Channel 9

Something went wrong getting user information from Channel 9

Latest Achievement:

Loading User Information from MSDN

Something went wrong getting user information from MSDN

Visual Studio Achievements

Latest Achievement:

Loading Visual Studio Achievements

Something went wrong getting the Visual Studio Achievements

Silverlight 4 Beta Networking. Part 1 - WebClient and XML

Download

Right click “Save as…”

  • WMV (WMV Video)
  • MP3 (Audio only)
  • MP4 (iPhone, Android)
  • Mid Quality WMV (Lo-band, Mobile)
A set of short screencasts providing a "tour" of the network capabilites in the Silverlight 4 beta. We'll look at raw HTTP access, socket access and WCF capabilities.

In this video, we take a look at doing a simple HTTP GET for an XML file with the WebClient API and then reading that with LINQ to XML.

The next video in this series is here.

Tags:

Follow the Discussion

  • Mike,

     

    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?

  • Mike Taultymtaulty Mike Taulty

    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 ).
    Mike.

  • 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

  • Mike Taultymtaulty Mike Taulty

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

     

    Mike.

  • Mike Taultymtaulty Mike Taulty

    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.

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

  • Mike Taultymtaulty Mike Taulty

    Jon,

     

    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?

     

    Mike.

  • sam_saltsam_salt

    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_DownloadStringCompleted);

     





    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
    )

  • SujeetSujeet

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

Remove this comment

Remove this thread

close

Comments Closed

Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums,
or Contact Us and let us know.