How do you set the base address of your API without hardcoding it?

99 Views Asked by At

I'm using HttpClientFactory to make API calls in a client application. The API and the client app are both in the same Visual Studio solution. When executing my solution both apps are running on localhost on different ports. When creating an HttpClient instance I set the baseaddress uri like this httpClient.BaseAddress = new Uri("https://localhost:7854");.

With "not hardcoding it" I mean: I don't want to put the Uri in any code or config or json file or Azure Key Vault or whatever.

I want to avoid hardcoding the address and find an easier way since both Apps are in the same solution. Is there a way to achieve what I want?

0

There are 0 best solutions below