C#C
C#3y ago
Daryl

❔ httpClient.PostAsync() - Program exits and never hits my breakpoint after?

This is the code:
    public async Task<string> RegisterAgent(string symbol, string faction)
    { 
        string url = apiUrl + "register";
        AgentRequest newAgent = new AgentRequest(symbol, faction);

        var content = JsonContent.Create(newAgent, mediaTypeHeaderValue);
        var response = await httpClient.PostAsync(url, content);
        response.EnsureSuccessStatusCode();

        System.Console.WriteLine(response.Content);
        return "";
    }


When I step through the code with my debugger it gets as far as var response... and then the application exits.... It should get to the code below.

I don't know if this changes things but core is a class in a Class Library. I am using a Unit Test to run the test.

Sorry if this is a really stupid question but I'm stumped.
image.png
Was this page helpful?