Migrate ASP.NET Core 5 App to .Net 6 (using Minimal hosting model)

628 Views Asked by At

I want to migrate a simple .NET 5 app to .Net 6. I have followed the microsoft docs that suggests changing the sdk to 6.0 and also I used the default Program.cs file for .net 6 that looks like this, since it's an empty project

using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddControllersWithViews();
var app = builder.Build();

if (app.Environment.IsDevelopment())
{
    app.UseDeveloperExceptionPage();
}

else
{
    app.UseExceptionHandler("/Home/Error");
    app.UseHsts();
}

app.UseHttpsRedirection();
app.UseStaticFiles();
app.UseRouting();

app.UseAuthorization();

app.MapControllerRoute(
    name: "default",
    pattern: "{controller=Home}/{action=Index}/{id?}");

app.Run();

Everything seems fine, no errors or warnings. But when I run the app, there's no css styling on the page. I've tried upgrading/installing the latest version of bootstrap and other packages but can't seem to resolve the issue. I want to completely get rid of the startup.cs file. Any help will be appreciate.

0

There are 0 best solutions below