你好朋友,我正在从 Windows 8 Store 应用程序调用 1 个休息服务,该服务托管在返回 JSon 数据的 wamp 服务器上。当我从浏览器输入该 URL 时,它会显示正确的 JSON 数据,但每当我尝试通过代码调用时使用 HttpClient,它会抛出异常“ An attempt was made to access a socket in a way forbidden by its access permissions 192.168.2.161:8080
”
堆栈跟踪:在 System.Net.ServicePoint.ConnectSocketInternal 的 System.Net.Sockets.Socket.EndConnect(IAsyncResult asyncResult) 处(布尔连接失败,套接字 s4,套接字 s6,套接字和套接字,IPAddress 和地址,ConnectSocketState 状态,IAsyncResult asyncResult,异常和异常)
try
{
HttpClient http = new System.Net.Http.HttpClient();
HttpResponseMessage response = await http.GetAsync("http://192.168.2.161:8080/Demo/?q=lgwebservice/Demo-Services");
string res = response.Content.ToString();
}
catch(Exception ex)
{}