Skip to content

Fast.NET.Core

Public members, parameters, returns, and exceptions

Targets: net8.0;net9.0;net10.0.

Contract and constraints

Application initialization, JSON configuration discovery, CORS, compression and request buffering. Initialize() returns the original WebApplicationBuilder, prints the startup banner, stores environment/configuration and registers framework services; it has observable side effects. Configuration scanning includes the executable directory and the configured scan directories. AddGzipCompression() registers services and UseGzipCompression() enables middleware. EnableBuffering() does not reset a request stream for the caller. GetRequestMethod() returns Unknown without a request. CORS callback overloads do not apply post-configuration defaults automatically. Configure trusted proxies explicitly: initialization enables forwarded address/protocol processing and clears known proxy collections. RemoteRequestUtil performs real network I/O and ShellUtil starts real processes.

Installation and examples

Install the package

bash
dotnet add package Fast.NET.Core

Example 1

csharp
using Fast.NET.Core;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;

var builder = WebApplication.CreateBuilder(args);
builder.Initialize();
builder.Services.AddControllers();
builder.AddCorsAccessor();
builder.Services.AddGzipCompression();

var app = builder.Build();
app.UseGzipCompression();
app.EnableBuffering();
app.MapControllers();
app.MapGet("/environment", () => new { builder.Environment.EnvironmentName });
app.Run();

Web-host examples belong in a consumer project using Microsoft.NET.Sdk.Web and a supported .NET target. IaaS examples can be used in an ordinary class library. Registration precedes builder.Build(); configure middleware and endpoints before app.Run(). Samples retain their original code and comments. No host, external service, database operation or client generator was run, and these snippets have not been compiled in this update.

Source reference

Background service resolution

Background callers must explicitly own a scope and pass its provider. FastContext.GetService/GetRequiredService no longer allocate implicit scopes for non-singletons. Request completion does not dispose a global background-object collection; explicitly registered application-level objects are released on application stop.