C#C
C#3y ago
Tantrim

❔ Unable to resolve service type for IHttpClientFactory

I'm hitting a wall on what to do.

I have two .NET 7.0 applications. One of which an API and the other a Web App.
Both apps are using the same version of System.Net.Http and builder.Services.AddHttpClient() doesn't seem to do anything. This is my first project working with API's like this so I'm a little lost on what to do. I'm willing to screen share if someone wants to hop in voice.

// API Project
// Program.cs
var builder = WebApplication.CreateBuilder(args);

// Add services to the container
builder.Services.AddControllers();
// Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddHttpClient();

builder.Services.AddLogging();
builder.Services.AddSwaggerGen();

var app = builder.Build();

// Configure the HTTP request pipeline.
if (app.Environment.IsDevelopment())
{
    app.UseSwagger();
    app.UseSwaggerUI();
}

app.UseHttpsRedirection();
app.UseAuthorization();

app.MapControllers();
app.Run();
Was this page helpful?