从Windows Phone 8的安全网站检索数据

本文关键字:安全网 网站 检索 数据 安全 Windows Phone | 更新日期: 2023-09-27 18:13:17

我正试图从授权限制数据库检索数据,该数据库仅包含文本到我的Windows Phone 8应用程序。我的代码看起来像这样:

private void Button_Click_1(object sender, RoutedEventArgs e)
{
    WebClient wc = new WebClient();
    wc.DownloadStringCompleted += new DownloadStringCompletedEventHandler(wc_DownloadStringCompleted);
    wc.Credentials = new NetworkCredential("username", "password");
    wc.DownloadStringAsync(new Uri(@"http://www.siteaddress.com"));
}
void wc_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
    string text = e.Result;
}

不幸的是,我得到以下消息。我做错什么了吗?提前感谢。http://s30.postimg.org/yuc0mcb5t/pic.png

从Windows Phone 8的安全网站检索数据

如果您试图将数据发送到服务器以接收服务器的响应,那么您的意思是将数据POST到服务器。

void GetPosts(string UserID)
    {
        WebClient webclient = new WebClient();
        Uri uristring = new Uri("somelink.com");
        webclient.Headers["Content-Type"] = "application/x-www-form-urlencoded";
        string postJsonData = string.Empty;
        postJsonData += "userId=" + UserID;//parameters you want to POST
        webclient.UploadStringAsync(uristring, "POST", postJsonData);
        webclient.UploadStringCompleted += webclient_UploadStringCompleted;
    }
    void webclient_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
    {
        .... // any code
    }