I am Susil

dotnet core has been seeing drastic improvements in its startup performance. It separated services extensions required for asp.net and console application. Now with .net 6 it has gone and providing bare minimum startup code. You will need .net 6 preview to be installed.

Create a new web application from terminal with .net 6 preview sdk

dotnet new web –o minimalapi

Project is created with just program.cs and you would not have startup.cs file containing all bootstrapping code

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

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

app.MapGet("/", () => "Hello World!");

app.Run();

Its just super simple hello world code that any dotnet developer would have wanted something similar to starting a node js application. Run the application and you will be presented with “Hello World!”

                  HelloWorld

You could add service extension like full blown application by adding package reference and including the code

...
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();

...

app.UseSwagger();
app.MapGet("/", () => "Hello World!");
app.UseSwaggerUI();

...

Refer Hanselman blog post for additional details


Comment Section

Comments are closed.