Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Service Discovery: How to Resolve It?#13204

Unanswered
thuptit asked this question inQ&A
Nov 26, 2025· 1 comments· 1 reply
Discussion options

Hi, I’ve already set up the microservices project and am now trying to adopt .NET Aspire. However, the issue is that we are using HttpClientFactory.Create() for dynamic facade service calling. This works well in a Docker Compose environment, but Aspire encourages defining a specific HttpClient for each service, which feels less dynamic and requires more effort. What would be the better approach in this case?

You must be logged in to vote

Replies: 1 comment 1 reply

Comment options

What isHttpClientFactory.Create()?

You must be logged in to vote
1 reply
@thuptit
Comment options

Thanks for your response!
This is an example:

varurl=configuration.GetValue<string>($"ServiceApiLocations:{serviceName}");if(string.IsNullOrEmpty(url)){thrownewArgumentException($"ServiceApiLocations:{serviceName} is null or empty");}varclient=newApiClient(httpClientFactory,serviceProvider.GetRequiredService<ILogger<ApiClient>>(),serviceProvider.GetRequiredService<IHostEnvironment>(),newUri(url),jsonSerializerSettings);// httpClientFactory is injected via constructorreturnclient;//Inside api clientpublicApiClient(IHttpClientFactory httpClientFactory,ILogger logger,IHostEnvironment hostEnvironment,Uri baseAddress,JsonSerializerSettings? jsonSerializerSettings=null){this.httpClient=httpClientFactory.CreateClient("httpClient");this.httpClient.BaseAddress=baseAddress;this.jsonSerializerSettings=jsonSerializerSettings??newJsonSerializerSettings();this.logger=logger;}

When send the request it's thrown an exception: "no such host is known"

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
2 participants
@thuptit@davidfowl

[8]ページ先頭

©2009-2025 Movatter.jp