Program file

Examine the program.cs file created

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

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

app.Run();

Just like any other.net app the program.cs file is the entry point to the application, right now it just listens to the base URL and maps requests to an anonymous function which returns hello world string.

The WebApplication.CreateBuilder is the API we use to build our web app and configure it the way we need it.

At this point it is impossible to serve HTML files or razor files since we don't have the necessary infrastructure for it. Even if we hardcode HTML content as string, it still renders as text only on browser!

Enable hot reload

Edit the message

Edit the message hello world with any string of your choice and save the file, you will see that the browser refreshes immediately without re running the application since we have enabled hot reload!

Last updated