user3656651
user3656651

Reputation: 820

Understanding .NET Core HttpClient.GetStringAsync

I want to understand what the following code is doing (it's from a tutorial):

        string token = await _httpClient.GetStringAsync("example-data/token.json");

My understanding is that _httpclient is used to call a Uri. Is this code making a network trip at all? What is the Uri here? What is returned?

Upvotes: 0

Views: 549

Answers (1)

Steven Frew
Steven Frew

Reputation: 214

HttpClient can be initialized with a BaseAddress, after which any URLs supplied to the various GetBlah methods can be relative to that (which is what appears to be the case here). GetStringAsync will return the response as a string.

Upvotes: 1

Related Questions