I'm trying to use the WebClient to access a URL that looks like this:
http://localhost:8080/html.ng/network=fim&size=movepre&property=foo&pagetype=bar¶ms.styles=html_vod&special=hlutest
It fails everytime. It is not a cross-domain issue as I'm perfectly able to download other files from more 'normal' looking URLs.
To test this I setup a local Apache server with two rewrite rules which pointed to a static text file. The first rule handled anything looking like the URL above, the second handled the URL "/foo".
I then created a new SL project and attempted to access the URL and display the contents of the result. Whenever I used "http://localhost:8080/html.ng/network=fim&size=movepre&property=foo&pagetype=bar¶ms.styles=html_vod&special=hlutest" as the URL
I always get an error: "Download Failure". However, if I use "http://localhost:8080/foo" I'm able to get the file just fine. I checked both URLs in my browser -- they worked correctly.
I also created a WinForms application and used the WebClient to fetch the first URL --
itworked. So this problem seems unique to Silverlight.
Can you show me which code you wrote at that side?
I have tested as below. It works.
Page.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Net;
using System.IO;
namespace SL2RespWrt {
public partial class Page : UserControl {
public Page() {
InitializeComponent();
WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
webClient.DownloadStringAsync(new Uri("http://localhost:51094/SL2RespWrt_Web/Default.aspx?text=1"));
}
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["text"].ToString() ==
"1") {
Response.Write("This is a string");
}
}
}
Yes. My sample is very simple one. So, it wont be like that in your case. It would be great if you can mention what you did step by step to reproduce the issue.
(If this has answered your question, please click on "Mark as Answer" on this post. Thank you!)
So as Karen pointed out in your original thread, the problem is you have a = in the path, which is not allowed in Beta1.
shanaolanxing - I'll transfer to the Windows Azure team, and will have limited time to participate in the Silverlight forum. Apologize if I don't answer your questions in time.
So as Karen pointed out in your original thread, the problem is you have a = in the path, which is not allowed in Beta1.
And probably the & too.
Besides allowing certain characters in beta 2 maybe they could just add a new attribute to the clientaccesspolicy.xml to disable this limitation for certain domains. I can always hope...
Karen's blog post about it covers it in much more detail, but the problem is that you can't have certain characters in
the path portion of URL, having those in the querystring is OK.
brown950
Member
20 Points
14 Posts
SL2 Beta - WebClient Unable to Access Certain URLs (not a cross-domain issue)
May 03, 2008 10:48 PM | LINK
I'm trying to use the WebClient to access a URL that looks like this:
http://localhost:8080/html.ng/network=fim&size=movepre&property=foo&pagetype=bar¶ms.styles=html_vod&special=hlutest
It fails everytime. It is not a cross-domain issue as I'm perfectly able to download other files from more 'normal' looking URLs.
To test this I setup a local Apache server with two rewrite rules which pointed to a static text file. The first rule handled anything looking like the URL above, the second handled the URL "/foo".
I then created a new SL project and attempted to access the URL and display the contents of the result. Whenever I used "http://localhost:8080/html.ng/network=fim&size=movepre&property=foo&pagetype=bar¶ms.styles=html_vod&special=hlutest" as the URL I always get an error: "Download Failure". However, if I use "http://localhost:8080/foo" I'm able to get the file just fine. I checked both URLs in my browser -- they worked correctly.
I also created a WinForms application and used the WebClient to fetch the first URL -- it worked. So this problem seems unique to Silverlight.
webclient uri url download failure
mchlSync
Star
14968 Points
2799 Posts
Re: SL2 Beta - WebClient Unable to Access Certain URLs (not a cross-domain issue)
May 04, 2008 07:44 AM | LINK
Can you show me which code you wrote at that side?
I have tested as below. It works.
Page.xaml.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Net;
using System.IO;
namespace SL2RespWrt {
public partial class Page : UserControl {
public Page() {
InitializeComponent();
WebClient webClient = new WebClient();
webClient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(webClient_DownloadStringCompleted);
webClient.DownloadStringAsync(new Uri("http://localhost:51094/SL2RespWrt_Web/Default.aspx?text=1"));
}
void webClient_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e) {
if ((e.Error == null) && (e.Cancelled == false)) {
string stream = e.Result;
}
}
}
}
Default.aspx
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Default.aspx.cs
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Request.QueryString["text"].ToString() ==
"1") {
Response.Write("This is a string");
}
}
}
SL2RespWrtTestPage.aspx
<%@ Page Language="C#" AutoEventWireup="true" %>
<%@ Register Assembly="System.Web.Silverlight" Namespace="System.Web.UI.SilverlightControls"
TagPrefix="asp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" style="height:100%;">
<head runat="server">
<title>Test Page For SL2RespWrt</title>
</head>
<body style="height:100%;margin:0;">
<form id="form1" runat="server" style="height:100%;">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<div style="height:100%;">
<asp:Silverlight ID="Xaml1" runat="server" Source="~/ClientBin/SL2RespWrt.xap" Version="2.0" Width="100%" Height="100%" />
</div>
</form>
</body>
</html>
Yes. My sample is very simple one. So, it wont be like that in your case. It would be great if you can mention what you did step by step to reproduce the issue.
Regards,
Michael Sync
Silverlight MVP
Blog : http://michaelsync.net
brown950
Member
20 Points
14 Posts
Re: SL2 Beta - WebClient Unable to Access Certain URLs (not a cross-domain issue)
May 04, 2008 03:39 PM | LINK
Test code posted in original thread at http://silverlight.net/forums/t/15410.aspx
Yi-Lun Luo -...
All-Star
25149 Points
2759 Posts
Microsoft
Re: Re: SL2 Beta - WebClient Unable to Access Certain URLs (not a cross-domain issue)
May 06, 2008 08:31 AM | LINK
So as Karen pointed out in your original thread, the problem is you have a = in the path, which is not allowed in Beta1.
brown950
Member
20 Points
14 Posts
Re: Re: SL2 Beta - WebClient Unable to Access Certain URLs (not a cross-domain issue)
May 06, 2008 01:47 PM | LINK
And probably the & too.
Besides allowing certain characters in beta 2 maybe they could just add a new attribute to the clientaccesspolicy.xml to disable this limitation for certain domains. I can always hope...
mchlSync
Star
14968 Points
2799 Posts
Re: Re: SL2 Beta - WebClient Unable to Access Certain URLs (not a cross-domain issue)
May 07, 2008 08:06 AM | LINK
I tried like that webClient.DownloadStringAsync(new Uri("http://localhost:51094/SL2RespWrt_Web/Default.aspx?text=1")); and it works.
Any idea? I can mail you the sample project if you wanna take a look.
Regards,
Michael Sync
Silverlight MVP
Blog : http://michaelsync.net
brown950
Member
20 Points
14 Posts
Re: Re: SL2 Beta - WebClient Unable to Access Certain URLs (not a cross-domain issue)
May 07, 2008 02:43 PM | LINK
Karen's blog post about it covers it in much more detail, but the problem is that you can't have certain characters in the path portion of URL, having those in the querystring is OK.