Quick Silverlight Tip: Networking in Silverlight 2.0 or my I’m getting HttpStatusCode.NotFound

If you’re trying to implement sample XSS networking with Silverlight as it explained in QuickStart guide, but with your own remote host, you’ll probably get strange "Not Found" error. You’ll check your host, firewall setting, etc and everything looks ok. So what’s the problem?

HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(new Uri("http://blogs.microsoft.co.il/blogs/tamir"));
           req.BeginGetResponse(getResponse, req);

void getResponse(IAsyncResult ar)
        {
           HttpWebRequest req = (HttpWebRequest)ar.AsyncState;
            HttpWebResponse res = (HttpWebResponse)req.EndGetResponse(ar);
            if (res.StatusCode == HttpStatusCode.OK)

 

WebClient client = new WebClient(new Uri("http://blogs.microsoft.co.il/blogs/tamir"));
            client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(client_DownloadProgressChanged);
            client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
            client.DownloadStringAsync();

void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
       {
           //DONE
       }

       void client_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
       {
           //Update progress
       }

The reason for it, two small lines in the guide: "Note that the server hosting the feed must opt-in to cross-domain access by providing a Clientaccesspolicy.xml or Crossdomain.xml file at the root of the domain."

Oh, baby, how can I missed it? Create your own Crossdomain.xml now and put it into root directory of your web server. Remember to register XAP MIME type too :)

Have a nice day

2 Responses to “Quick Silverlight Tip: Networking in Silverlight 2.0 or my I’m getting HttpStatusCode.NotFound”

  1. Quick Silverlight Tip: Networking in Silverlight 2.0 or my I'm … | Quick Work Says:

    Pingback from  Quick Silverlight Tip: Networking in Silverlight 2.0 or my I'm … | Quick Work

  2. Quiksilver Vintage fan website 1986 1987 1988 galleries with many pics of vintage items : boardshorts, jackets, caps, tee shirts, warpaint, ghetto dog, generation x Says:

    Howdy very nice web site!! Man .. Excellent .. Superb .. I’ll bookmark your blog and take the feeds also?I am glad to find a lot of helpful info here within the put up, we need develop more techniques in this regard, thanks for sharing. . . . . .

Leave a Reply

Recommended

 


Sponsor


Partners

WPF Disciples
Dreamhost
Code Project
Switched to Better Place

Together