2

According to this

https://msdn.microsoft.com/en-us/library/system.net.http.httpclient.baseaddress(v=vs.118).aspx

It contains the base address. Well, duh....

I do not know if microsoft documentation is meant to be understood. What the hell is base address?

Is it the URL with only hostname?

Like StackOverflow.com?

Is it the whole URL like stackoverflow.com/question/ask

Is it the whole URL including the parameter, such as stackoverflow.com/hello/world?dfdsdf=34fgdsg

What is base address?

Hadi
  • 36,233
  • 13
  • 65
  • 124
user4951
  • 32,206
  • 53
  • 172
  • 282

1 Answers1

5

httpclient.baseaddress is used as the starting point to send your http requests.

Example

If you have to send many requests starting with the same address

https://stackoverflow.com/hello/moreinfo1/1
https://stackoverflow.com/hello/moreinfo2/2

So you have to set

clt.baseaddress = New Uri("https://stackoverflow.com/hello/")
Dim response1 As HttpResponseMessage = Await clt.GetAsync("moreinfo1/1")
Dim response2 As HttpResponseMessage = Await clt.GetAsync("moreinfo2/2")

Else (if not set baseaddress property) you have to write the full URI every time you are sending a request

Dim response1 As HttpResponseMessage = Await clt.GetAsync("https://stackoverflow.com/hello/moreinfo1/1")
Dim response2 As HttpResponseMessage = Await clt.GetAsync("https://stackoverflow.com/hello/moreinfo2/2")

Useful Links

Brad
  • 11,934
  • 4
  • 45
  • 73
Hadi
  • 36,233
  • 13
  • 65
  • 124