【发布时间】:2015-03-02 15:26:42
【问题描述】:
我有以下问题: 我有代码
string url = "https://api.vkontakte.ru/oauth/access_token?client_id=123&client_secret=qqq&code=123&redirect_uri=myurl.com";
var webRequest = (HttpWebRequest)WebRequest.Create(url);
// here I've got my exception
using (var response = (HttpWebResponse)webRequest.GetResponse())
{
using (var reader = new StreamReader(response.GetResponseStream()))
{
Console.WriteLine("response = " + reader.ReadToEnd());
}
}
我在控制台应用程序中执行此代码,它工作正常。但是,当我在 asp.net 应用程序中使用此代码时,它会因“无法连接到远程服务器”异常而失败。 Црн 它发生了吗?我该如何解决?
【问题讨论】:
-
在asp.net应用程序中使用时,你的意思是在本地调试还是在服务器上调试时出现这种情况?
-
本地调试时发生
标签: c# exception httpwebrequest