© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
26 replies
Metalkon

HttpClient only working in Main but not in another Class? [Answered]

I'm currently following a c# json tutorial and trying to put this code into it's own class so I can keep multiple code references in a single project. Everything works fine in Main but when I try to put it into another class it won't work properly, anyone have an idea on what I might be missing?

When I run it in main I get the json details printed in the console window, but when i run it in the class it's blank.

The only thing in the main method is JsonServer.Run();
unknown.png
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

✅ Access array in another class
C#CC# / help
4y ago
✅ Best practice when using HttpClient in a class
C#CC# / help
3y ago