0

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?

1 Answer 1

1

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.

Sign up to request clarification or add additional context in comments.

1 Comment

So the base address is set like this: new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); so it is "/". What does that resolve to for HttpClient?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.