添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement . We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I really need to use Httpclientfactory in an existing project,
but when i try to use it I get an error. I search High and low, but no way i could get it work with an existing project which uses Castle Windsor. Using a new console app and registering
services.AddHttpClient("API", c =>
c.BaseAddress = new Uri(Program.ApiUrl);
c.DefaultRequestHeaders.Clear();
c.DefaultRequestHeaders.Add("Accept", "application/json");

and adding services.AddTransient<IAPIService, APIService>();
gives me no problem at all and all works even with injecting like :
private readonly IHttpClientFactory _clientFactory;
public HaydigoAPIService(IHttpClientFactory clientFactory, IHostApplicationLifetime applicationLifetime)

But with widsor project even this doesnt work. Can anybody please help me to get this working? I search all google to find solution for this but I could not. Thank you!

private readonly IHttpClientFactory _clientFactory; public APIService() { _clientFactory = IocManager.Resolve<IHttpClientFactory>(); }

"No component for supporting the service System.Net.Http.IHttpClientFactory was found"

Is there a way I can register the IHttpClientFactory with Castle windsor? in
public void Install(IWindsorContainer container, IConfigurationStore store)

You haven't provided a full repro of your code with Windsor, but have you registered a component for the IHttpClientFactory service? i.e. have you called container.Register(... to provide Windsor an implementation of IHttpClientFactory so it can instantiate an instance for you?

Or is this using the Winsdor's ASP.NET Core facility to bridge the 2 containers?

Urgent: IHttpClientFactory registration .net core 3.1? IHttpClientFactory registration .net core 3.1? Aug 31, 2020