我正在使用 WebClient 从 web 获取页面,当我得到 google 起始页面时一切正常,但是当我从 vk api WebClient 获取页面时返回 Serer 未找到,但浏览器正常打开此页面我的代码:
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);
}