An implementation optimized for web applications that is managed by its host.
$ dotnet add package Codebelt.Bootstrapper.WebAn open-source family of assemblies (MIT license) that provide a uniform and consistent way of bootstraping your code with Program.cs paired with Startup.cs.
Also, common for all, is the implementation of the IHostedService interface; this means that all project types, including the traditional console, now have option for graceful shutdown should your application require this (cronjob scenarios or similar).
Your versatile Bootstrapper companion for modern development with .NET 9 and .NET 10.
It is, by heart, free, flexible and built to extend and boost your agile codebelt.
An implementation optimized for web, webapi, webapp, razor, mvc applications.
An example on how to use Codebelt.Bootstrapper.Web in C#:
// --- Program.cs ---
public class Program : WebProgram<Startup>
{
static async Task Main(string[] args)
{
await CreateHostBuilder(args)
.Build()
.RunAsync()
.ConfigureAwait(false);
}
}
// --- Startup.cs ---
public class Startup : WebStartup
{
public Startup(IConfiguration configuration, IHostEnvironment environment) : base(configuration, environment)
{
}
public override void ConfigureServices(IServiceCollection services)
{
}
public override void ConfigurePipeline(IApplicationBuilder app)
{
if (Environment.IsLocalDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello World!");
});
});
}
}
And the minimal equivalent example on how to use Codebelt.Bootstrapper.Web in C#:
// --- Program.cs ---
public class Program : MinimalWebProgram
{
static Task Main(string[] args)
{
var builder = CreateHostBuilder(args);
var app = builder.Build();
if (app.Environment.IsLocalDevelopment())
{
app.UseDeveloperExceptionPage();
}
app.UseRouting();
app.UseEndpoints(endpoints =>
{
endpoints.MapGet("/", async context =>
{
await context.Response.WriteAsync("Hello World!");
});
});
return app.RunAsync();
}
}