简体   繁体   中英

Reusing HttpClient with multiple base addresses

I have dotnet core web api hosted on Azure. The Web API works as a HUB, where it has to distribute the message to different endpoints every time based on certain criteria and my HttpClientHandler is the same always. How do I reuse the HttpClient with multiple base addresses.

HttpClient.BaseAddress is a convenience feature that exists specifically for scenarios where you're making calls to the same base address. You're doing the opposite of that, and you're not required to set it, so don't. Just set the absolute URI for each request.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM