System.Net.Http.HttpRequestException:未配置设备---> System.Net.Sockets.SocketException:未配置设备

Cor*_*y P 5 c# middleware httprequest visual-studio asp.net-core

System.Net.Http.HttpRequestException:未配置设备---> System.Net.Sockets.SocketException:未配置设备

尝试从自定义中间件生成aspnet核心Web应用程序的Web请求时,我收到上述错误。该错误发生在以下代码块的第四行:

var web = new WebClient();
var testing = _configuration.GetSection("IPStack")["AccessKey"];
web.QueryString.Add("access_key", _configuration.GetSection("IPStack")["AccessKey"]);
string ipstackRaw = web.DownloadString($"http://api.ipstack/{ipaddress}");
Run Code Online (Sandbox Code Playgroud)

我正在Mac社区版上使用Visual Studio。是什么导致此错误?

更新资料

自原始帖子以来,我已经尝试了一些方法,但均未成功。这是我尝试过的:

  • 在PC上的Visual Studio专业版中运行应用程序(Windows 10)
  • 使用HttpClient尝试请求
  • 在中间件之外尝试请求

Cor*_*y P 5

确保正确键入请求 URI。

更改
string ipstackRaw = web.DownloadString($"http://api.ipstack/{ipaddress}");

string ipstackRaw = web.DownloadString($"http://api.ipstack.com/{ipaddress}");