Skip to main content

Microsoft Silverlight

Answered Question WebClient Download Failure For Certain URLRSS Feed

(0)

brown950
brown950

Member

Member

20 points

14 Posts

WebClient Download Failure For Certain URL

I'm trying to use the WebClient to retrieve data from a page but it never works, always resulting in the error message: Download Failure.  I do have the necessary cross-domain XML files in place and I have tested using the WebClient to retrieve other files from this site with no problem.  I've been doing a lot of testing and the problem seems to be the URL, but I'm not sure how to fix that.

An example of the URL in question is: http://localhost:8080/html.ng/network=fim&size=movepre&property=foo&pagetype=bar&params.styles=html_vod&special=hlutest

However, if the URL were something like: http://localhost:8080/testdata.txt, it loads fine.

I tested this out using Apache and some rewrite rules to rewrite anything looking like the first URL or something like /foo to a static text file.  Both URLs work fine in my browser, but the first ALWAYS fails in Silverlight 2 while the second always works.

However, I did create a WinForms application and it works fine using the first URL.  So I'm not sure if this is an issue with the Silverlight WebClient or Uri class.

Any suggestions?

 

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Re: WebClient Download Failure For Certain URL

No good suggestion, my guess is that since you're URI doesn't have traditional query string syntax that the URI class is choking on the syntax.  That seems like a bug in Silverlight, not necessarily something for you to fix on the server.

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Re: WebClient Download Failure For Certain URL

No good suggestion, my guess is that since you're URI doesn't have traditional query string syntax that the URI class is choking on the syntax.  That seems like a bug in Silverlight, not necessarily something for you to fix on the server.

 

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Re: WebClient Download Failure For Certain URL

No good suggestion, my guess is that since you're URI doesn't have traditional query string syntax that the URI class is choking on the syntax.  That seems like a bug in Silverlight, not necessarily something for you to fix on the server.

 You

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Re: WebClient Download Failure For Certain URL

No good suggestion, my guess is that since you're URI doesn't have traditional query string syntax that the URI class is choking on the syntax.  That seems like a bug in Silverlight, not necessarily something for you to fix on the server.

 You might

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Re: WebClient Download Failure For Certain URL

No good suggestion, my guess is that since you're URI doesn't have traditional query string syntax that the URI class is choking on the syntax.  That seems like a bug in Silverlight, not necessarily something for you to fix on the server.

 You might get

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Re: WebClient Download Failure For Certain URL

No good suggestion, my guess is that since you're URI doesn't have traditional query string syntax that the URI class is choking on the syntax.  That seems like a bug in Silverlight, not necessarily something for you to fix on the server.

 You might get away with

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Re: WebClient Download Failure For Certain URL

No good suggestion, my guess is that since you're URI doesn't have traditional query string syntax that the URI class is choking on the syntax.  That seems like a bug in Silverlight, not necessarily something for you to fix on the server.

 You might get away

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Re: WebClient Download Failure For Certain URL

No good suggestion, my guess is that since you're URI doesn't have traditional query string syntax that the URI class is choking on the syntax.  That seems like a bug in Silverlight, not necessarily something for you to fix on the server.

 You might get away with it if you

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com

swildermuth
swildermuth

Star

Star

8320 points

1,546 Posts

Re: WebClient Download Failure For Certain URL

Sorry for the mulitple posts...the AJAX driven reply window is freaking out (and submitted the form as I typed).

 One thing you can try is to URL encode it using HtmlUtility.UrlEncode().

(If this has answered your question, "Mark as Answer")

Shawn Wildermuth
C# MVP, MCSD, Speaker and Author

Silverlight 3 Workshop
Miami, FL: Oct 12-14th
Portlant, OR: Dec 2-4th
Atlanta, GA: Dec 7-9th
http://silverlight-tour.com

brown950
brown950

Member

Member

20 points

14 Posts

Re: WebClient Download Failure For Certain URL

Na, no luck with that.  I guess it is a Silverlight problem as it works fine in a WinForms app.  I went ahead and posted a thread in the bug forum, hopefully it'll get some attention.  Thanks for your suggestion though.

mchlsync
mchlsync

Star

Star

14606 points

2,730 Posts

Silverlight MVP

Re: WebClient Download Failure For Certain URL

brown950:
Na, no luck with that.  I guess it is a Silverlight problem as it works fine in a WinForms app.  I went ahead and posted a thread in the bug forum, hopefully it'll get some attention.  Thanks for your suggestion though.
 

Can you show me which code you wrote at that side?

I have tested like this and it works.

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Regards,
Michael Sync
Silverlight MVP

Blog : http://michaelsync.net


brown950
brown950

Member

Member

20 points

14 Posts

Re: WebClient Download Failure For Certain URL

So, the issue is the URL I'm using.  It's not something I have control over either except in my test environment.  Below is the code from my test SL and WinForms apps.  The SL one always fails, the WinForms one works.  In my thread in the bug forum which you replied to I did detail the steps necessary to reproduce it.  You simply need to setup a server that lets you access something (in my case a static text file), using a url such as: /html.ng/network=fim&size=movepre&property=ign&pagetype=e3_video_stream&params.styles=html_vod&special=hlutest

For that I used Apache and mod_rewrite with this rule: RewriteRule ^/html\.ng/ /testdata.txt

Here's the SL code:

namespace SilverlightApplication2
{
    public partial class Page : UserControl
    {
        public Page()
        {
            InitializeComponent();
            PollServer();
        }

        private void PollServer()
        {
            WebClient request = new WebClient();
            request.DownloadStringCompleted += new DownloadStringCompletedEventHandler(request_DownloadStringCompleted);
            request.DownloadStringAsync(new Uri("http://localhost:8080/html.ng/network=fim&size=movepre&property=ign&pagetype=e3_video_stream&params.styles=html_vod&special=hlutest"));
        }

        void request_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error != null)
            {
                Status.Text = e.Error.Message;
            }
            else
            {

               Status.Text = e.Result;
            }
        }
    }
}

And the WinForms test:

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            WebClient req = new WebClient();
            req.DownloadStringCompleted += new DownloadStringCompletedEventHandler(req_DownloadStringCompleted);
            req.DownloadStringAsync(new Uri("http://localhost:8080/html.ng/network=fim&size=movepre&property=ign&pagetype=e3_video_stream&params.styles=html_vod&special=hlutest"));
        }

        void req_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
        {
            if (e.Error == null)
            {
                textBox1.Text = e.Result;
            }
        }
    }
}

mchlsync
mchlsync

Star

Star

14606 points

2,730 Posts

Silverlight MVP

Re: WebClient Download Failure For Certain URL

brown950:

You simply need to setup a server that lets you access something (in my case a static text file), using a url such as: /html.ng/network=fim&size=movepre&property=ign&pagetype=e3_video_stream&params.styles=html_vod&special=hlutest

For that I used Apache and mod_rewrite with this rule: RewriteRule ^/html\.ng/ /testdata.txt

 

I don't have Apache server at my office. I will try this at my home.. I just need to put testdata.txt in htdocs folder and update the mod_rewrite? I will test and will let you know the result.

(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)

Regards,
Michael Sync
Silverlight MVP

Blog : http://michaelsync.net


brown950
brown950

Member

Member

20 points

14 Posts

Re: WebClient Download Failure For Certain URL

Yes, drop a file named "testdata.txt" into your htdocs directory and add the following to your httpd.conf.

RewriteEngine on
RewriteRule ^/html\.ng/ /testdata.txt

Karen Corby - MSFT
Karen Co...

Member

Member

40 points

5 Posts

Microsoft
Answered Question

Re: WebClient Download Failure For Certain URL

Hi,

The character limitation for cross-domain paths is by design in Beta1 as a security mitigation.  You can read more about the motivations in this blog post:  http://scorbs.com/2008/04/15/silverlight-http-networking-stack-part-2-cross-domain-communication-overview

 Right now, cross domain paths can include:

- Alphanumeric chars

- '/', '~', "-', "_", "."  (But no ".."s or "./" substrings)

We've already heard that ';', '=', and ',' are character limitations that are problematic, and we're addressing those for Beta2.  If you have additional blocked characters that are preventing you from accomplishing your scenario, we would love to hear about htem.

 

Thanks!
Karen

brown950
brown950

Member

Member

20 points

14 Posts

Re: WebClient Download Failure For Certain URL

Ah, well thank you for clearing that up.  Guess I'm looking forward to beta 2 even more.

Also not allowing "&" would be problematic at least in my case.

Maybe you guys could just add a new attribute to the clientaccesspolicy.xml to disable that limitation for certain domains.
 

  • Unanswered Question
  • Answered Question
  • Announcement
Microsoft Communities