Windows Phone 7,通过身份验证在ssl上下载xml

Sna*_*ake 3 .net silverlight windows-phone-7

我正在尝试从我的提供商处下载文件.

网址受基本用户名和密码保护,所有内容都通过ssl发送.

所以我尝试这样做:

        WebClient proxy = new WebClient();

        proxy.DownloadStringCompleted += (o, dscea) => System.Diagnostics.Debugger.Break();
        proxy.Credentials = new NetworkCredential("username", "password");
        proxy.DownloadStringAsync(new Uri("https://..../.../data.xml"));
Run Code Online (Sandbox Code Playgroud)

如您所见,我尝试验证.网址是正确的,当我尝试从twitter下载内容时代码可以正常工作.

当我在Firefox/Internet Explorer中输入URL时,URL可以正常工作

我忘了连接到这个xml文件了么?

我得到的错误如下:

我正在使用Visual Studio 2010(完整版,而不是Express版)和CTP刷新版:)

Joh*_*han 6

这似乎在Beta工具版本中得到修复.我不得不直接设置Authorization标头,因为.NET没有像你期望的那样处理基本的auth.这是我的工作代码片段:

var client = new WebClient();

var token = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}:{1}", username, password)));
var authHeader = string.Format("Basic {0}", token);

client.Headers["Authorization"] = authHeader;
client.DownloadStringCompleted += (s, e) =>
{
   // handle result
};

client.DownloadStringAsync(url);
Run Code Online (Sandbox Code Playgroud)