【问题标题】:Download a file over HTTPS in Windows phone在 Windows 手机中通过 HTTPS 下载文件
【发布时间】:2012-10-30 14:15:04
【问题描述】:

是否可以在 Windows 手机中通过 Https 下载文件,使用用户名和密码发布方法,我尝试了此代码,但它返回错误。 请注意,urlLink 是一个“https://”链接。

   Uri uri = new Uri(urlLink);
        HttpWebRequest r = (HttpWebRequest)WebRequest.Create(uri);
        r.ContentType = "application/x-www-form-urlencoded";
        r.Method = "POST";
        string parameters = "username=admin&password=123";
        r.BeginGetRequestStream(delegate(IAsyncResult req)
        {
            var outStream = r.EndGetRequestStream(req);

            using (StreamWriter w = new StreamWriter(outStream))
              w.Write(parameters);

            r.BeginGetResponse(delegate(IAsyncResult result)
            {
                try
                {
                    HttpWebResponse response = (HttpWebResponse)r.EndGetResponse(result);

                    using (var stream = response.GetResponseStream())
                    {
                        using (StreamReader reader = new StreamReader(stream))
                        {

                        }
                    }
                }
                catch (Exception exc)
                {
                    string ee = exc.Message;

                }
            }, null);
        }, null);

错误:

远程服务器返回错误:NotFound。

【问题讨论】:

  • 当您导航到“urlLink”时浏览器会说什么?
  • 此链接使用 POST 方法,因此无法在浏览器上运行,但我确信该链接可以正常运行。

标签: c# silverlight https download windows-phone


【解决方案1】:

因为它是https(使用SSL),所以手机需要先下载并安装服务器的证书,然后才能对其进行任何访问。

编辑:在这个答案中添加了我的评论,并删除了评论。

这是关于主题 http://msdn.microsoft.com/en-us/library/ms731899.aspx 的 MSDN 文档的链接

如果证书是自签名的,您可以使用模拟器下载并安装它,前提是您已将证书上传到可以下载的地方。请注意,每次启动模拟器时都需要安装证书(但不是每次启动应用程序调试时)。

【讨论】:

  • 所以我不能在模拟器上测试它?你能给我更多信息或链接,这将有助于我使用证书..
猜你喜欢
  • 1970-01-01
  • 2012-07-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2010-12-13
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多