Skip to content

Fast.NET.Core ​

Public members, parameters, returns, and exceptions

Reference source version 3.5.47; targets: net8.0;net9.0;net10.0.

When upgrading code that uses platform flags, see the Runtime H5 migration guide and the dependency history.

Contract and constraints ​

Application initialization, JSON configuration discovery, CORS, compression, request buffering and static-file MIME mappings. 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 ​

The Fast.NET getting started example is verified with 3.5.42.

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.

Static-file MIME mappings ​

Starting with 3.5.44, UseStaticFiles(IConfiguration configuration, string section = "StaticFileSettings") reads file-extension-to-MIME-type mappings from configuration and returns the original IApplicationBuilder for chaining.

Configure appsettings.json:

json
{
	"StaticFileSettings": {
		".txt": "text/plain; charset=utf-8",
		".custom": "application/octet-stream"
	}
}

Enable the middleware in a Web project's Program.cs:

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

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

app.UseStaticFiles(builder.Configuration);

app.Run();

Keys include the leading dot, and values are MIME types. Configured entries supplement or override the default FileExtensionContentTypeProvider mappings; other default mappings remain available. A missing or empty section still enables the middleware with its default mappings.

Use app.UseStaticFiles(builder.Configuration, "Files:MimeTypes") for a custom section path. This overload configures content-type mappings only; the file provider, request path and other options retain ASP.NET Core defaults. Place example files under the default Web root, wwwroot.

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.

Authentication status fix: preserve the final HTTP 401/403 without token-header-based conversion; never rewrite started responses or duplicate the body.

Dependency alignment on 2026-11-02 ​

2026-11-02 dependency alignment: this package increments from 3.5.46 to 3.5.47, updating its dependency to Fast.Runtime 3.5.37. This module's implementation and public declarations are unchanged. Runtime adds mobile H5 and shifts Android and subsequent flags; migrate numeric protocols/masks, rebuild consumers and regenerate client enums. See the Runtime H5 migration guide.

2026-10-24 versions and dependencies ​

On 2026-10-24, this package increments from 3.5.42 to 3.5.43, with dependencies updated to Fast.Runtime 3.5.34. This module's own implementation and public declarations are unchanged.

Consumers using AppEnvironmentEnum must migrate numeric values and rebuild according to the Runtime HarmonyOS migration guide. This batch reviewed source and effective MSBuild package metadata only. Tests were skipped as requested; no restore, build, pack or consumer runtime validation was performed.

2026-10-30 static-file mappings ​

Fast.NET.Core increments from 3.5.43 to 3.5.44, adding a UseStaticFiles overload that supplements or overrides static-file MIME mappings from configuration, with expanded XML documentation. The default section is StaticFileSettings; the Fast.Runtime 3.5.34 dependency is unchanged.

The static-file example compiled against the Core/Runtime assemblies built from the current source for net8.0, net9.0 and net10.0; no host or HTTP request was run. The existing getting-started example remains pinned to Fast.NET.Core 3.5.42 and does not validate the new entry point. Build, package and documentation validation results for this update are recorded in the version-review metadata.