System.Net.Http.HttpRequestException: Device not configured ---> System.Net.Sockets.SocketException: Device not configured
I'm receiving the above error when trying to make a web request from a custom middleware piece for an aspnet core web application. The error occurs on the fourth line of the following block of code:
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}");
I'm using Visual Studio on Mac, Community Edition. What's causing this error?
Update
I've tried a few things since the original post without success. Here is what I have tried:
Make sure you type the request URI correctly.
Change
string ipstackRaw = web.DownloadString($"http://api.ipstack/{ipaddress}");
to
string ipstackRaw = web.DownloadString($"http://api.ipstack.com/{ipaddress}");