首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Windows phone WebClient

Windows phone WebClient
EN

Stack Overflow用户
提问于 2012-08-14 20:06:00
回答 1查看 3.6K关注 0票数 1

我正在使用WebClient从网页获取页面,当我获得谷歌开始页面一切正常,但当我从vk应用程序接口WebClient返回服务器没有找到页面,但浏览器打开此页面正常我的代码:

代码语言:javascript
复制
private void log_Click(object sender, RoutedEventArgs e)
{
    string auth;
    string login = Uri.EscapeUriString(this.login.Text);
    string password = Uri.EscapeUriString(this.pass.Password);
    auth = "https://api.vk.com/oauth/token";
    auth += "?grant_type=password" + "&client_id=id&client_secret=code&username=" + login + "&password=" + password + "&scope=notify,friends,messages";

    //auth = "https://google.com/";

    WebClient client = new WebClient();
    client.DownloadStringCompleted +=new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
    Uri.EscapeUriString(auth);
    client.DownloadStringAsync(new Uri(auth));
}
void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
    if (e.Error == null)
         MessageBox.Show("Using WebClient: " + e.Result);

    else
        MessageBox.Show(e.Error.Message);
}
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-08-14 20:32:26

这仅适用于具有非200响应状态的https呼叫。如果您收到具有正确凭据的Not found,请检查您的请求参数。

尝试对非200使用此解决方法

代码语言:javascript
复制
client.AllowReadStreamBuffering = true;

另外,我看到这一行Uri.EscapeUriString(auth);,我想它一定是auth = Uri.EscapeUriString(auth);

票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/11951929

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档