© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
14 replies
Deleted User 93w4ls0g

❔ Local Environment throwing exception when calling HttpClient.GetStringAsync

I am running the below code via Visual Studio Code, and a "The requested address is not valid in its context. (www.mypublicwebsite.com:443)" exception is thrown, an inner SocketException with error code 10049 is thrown too but I cannot figure out why it is called, I believe my local is setup to allow the program to connect to public internet sites.

using (var httpClient = new HttpClient()) {
                    await httpClient.GetStringAsync("https://www.mypublicwebsite.com");
                }
using (var httpClient = new HttpClient()) {
                    await httpClient.GetStringAsync("https://www.mypublicwebsite.com");
                }
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

HttpClient.GetStringAsync() is slow
C#CC# / help
4y ago
❔ HttpClient exiting program during GetStringAsync() and GetAsync()
C#CC# / help
4y ago
❔ Testhost process crash when throwing an Exception and reading the Console.
C#CC# / help
4y ago
❔ HttpClient's DefaultRequestHeaders.Accept.Add throws null reference exception
C#CC# / help
3y ago