Tantrim
Tantrim
CC#
Created by Tantrim on 6/29/2024 in #help
INotifyPropertyChanged
No description
26 replies
CC#
Created by Tantrim on 4/18/2023 in #help
❔ 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();
// 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();
5 replies