I have added .NET Aspire to my ASP.NET Core Web API backend. But I get the following error when building the app on builder.MapDefaultEndpoints():
Error (active) CS1929 'WebApplicationBuilder' does not contain a definition for 'MapDefaultEndpoints' and the best extension method overload 'Extensions.MapDefaultEndpoints(WebApplication)' requires a receiver of type 'Microsoft.AspNetCore.Builder.WebApplication'
How can I solve this?
This is my program.cs:
try
{
Log.Information("Starting Rest API");
var builder = WebApplication.CreateBuilder(args);
var startup = new Startup(builder.Configuration);
startup.ConfigureServices(builder.Services);
builder.AddServiceDefaults();
builder.MapDefaultEndpoints();
ConfigureLogger(builder.Host);
var app = builder.Build();
startup.Configure(app, app.Environment);
app.Run();
}
catch (Exception ex)
{
Log.Fatal(ex, "Host terminated unexpectedly");
}
finally
{
Log.CloseAndFlush();
}
