![]() |
VOOZH | about |
dotnet add package Dosaic.Hosting.WebHost --version 1.2.34
NuGet\Install-Package Dosaic.Hosting.WebHost -Version 1.2.34
<PackageReference Include="Dosaic.Hosting.WebHost" Version="1.2.34" />
<PackageVersion Include="Dosaic.Hosting.WebHost" Version="1.2.34" />Directory.Packages.props
<PackageReference Include="Dosaic.Hosting.WebHost" />Project file
paket add Dosaic.Hosting.WebHost --version 1.2.34
#r "nuget: Dosaic.Hosting.WebHost, 1.2.34"
#:package Dosaic.Hosting.WebHost@1.2.34
#addin nuget:?package=Dosaic.Hosting.WebHost&version=1.2.34Install as a Cake Addin
#tool nuget:?package=Dosaic.Hosting.WebHost&version=1.2.34Install as a Cake Tool
Dosaic.Hosting.WebHost is the core orchestration package for any Dosaic-based service. It wires together plugin discovery, dependency injection, middleware pipeline configuration, health checks, OpenTelemetry, structured logging, CORS, response compression, IP rate limiting, and endpoint routing — all driven by the plugin interfaces from Dosaic.Hosting.Abstractions.
This package is mandatory. Without it no plugins can be loaded or configured.
dotnet add package Dosaic.Hosting.Generator # required for AOT-compatible plugin discovery
dotnet add package Dosaic.Hosting.WebHost
Or as package references in your .csproj:
<PackageReference Include="Dosaic.Hosting.Generator" Version="" />
<PackageReference Include="Dosaic.Hosting.WebHost" Version="" />
Replace the content of Program.cs with:
using Dosaic.Hosting.WebHost;
PluginWebHostBuilder.RunDefault(Dosaic.Generated.DosaicPluginTypes.All);
DosaicPluginTypes.All is a Type[] emitted at compile time by Dosaic.Hosting.Generator — no runtime reflection scanning is required.
For advanced scenarios (e.g. integration testing) you can separate build from run:
using Dosaic.Hosting.WebHost;
var host = PluginWebHostBuilder.Create(Dosaic.Generated.DosaicPluginTypes.All, args).Build();
host.Run();
| Feature | Details |
|---|---|
| AOT-compatible plugin discovery | Plugin types resolved from source-generated Type[] — no reflection at runtime |
| Structured logging | Serilog with span/thread enrichers, structured request logging |
| OpenTelemetry | Metrics, tracing (OTLP), and logging exporters; Prometheus scraping endpoint at /metrics |
| Health checks | Built-in liveness checks (API, disk, memory); plugin and attribute-driven registrations |
| CORS | Configurable policy via CorsPolicy config section |
| Response compression | Brotli + Gzip (fastest level), applied to HTTP and HTTPS |
| IP rate limiting | AspNetCoreRateLimit integration, configurable via ipRateLimiting section |
| Layered configuration | JSON, YAML, secrets files, env vars, CLI args — ordered by specificity |
| YAML input/output formatters | Controllers accept and return application/yaml in addition to JSON |
| Forwarded headers | All forwarded headers trusted (proxy-friendly) |
| Configurable Kestrel | Listening URLs and max request body size controlled via config |
PluginWebHostBuilder.Build() executes the following phases in order:
HostConfigurator)host:urls), max request body size (host:maxRequestSize), server header suppressionServiceConfigurator)[Configuration(...)]-attributed classes from IConfiguration[HealthCheck]-attributed types + plugin-contributed checksIPluginServiceConfiguration.ConfigureServices() on all discovered plugins (sorted by origin)WebApplicationBuilder.Build() finalises the DI container.
AppConfigurator)[Middleware]-attributed types ordered by their Order propertyIPluginApplicationConfiguration.ConfigureApplication() on all discovered plugins/health/liveness, /health/readiness)IPluginEndpointsConfiguration.ConfigureEndpoints() on all discovered pluginsTypeImplementationResolver.ClearInstances() disposes all plugin constructor instances created during build.
| Plugin origin | Sort key | Runs |
|---|---|---|
Dosaic.* namespace |
sbyte.MinValue |
First |
| Third-party plugins | 0 |
Middle |
| Host assembly plugins | sbyte.MaxValue |
Last |
host:
urls: "http://+:8080" # default; separate multiple URLs with ","
maxRequestSize: 8388608 # default 8 MB
Environment variables (single _ maps to : hierarchy):
HOST_URLS=http://+:8080
HOST_MAXREQUESTSIZE=8388608
Dosaic loads configuration in the following order (later sources override earlier ones):
appsettings.jsonappsettings.yaml / appsettings.ymlappsettings.*.jsonappsettings.*.yaml / appsettings.*.ymlappsettings.secrets.json / appsettings.secrets.yaml / appsettings.secrets.ymlappsettings.*.secrets.json / appsettings.*.secrets.yaml / appsettings.*.secrets.ymlFiles are sorted by node count (number of .-separated segments) within each group. Secrets files always load after non-secrets files. Files whose names do not start with appsettings are ignored.
You can load configuration files from additional directories. Those files are loaded before the main application directory.
Via environment variable:
HOST_ADDITIONALCONFIGPATHS=/path/to/configs,/another/path
Via command-line argument:
dotnet run --HOST:ADDITIONALCONFIGPATHS "/path/to/configs,/another/path"
appsettings.* files.json, .yaml, .yml formatsDirectoryNotFoundExceptionDosaic uses a custom provider that maps environment variable names to configuration keys by replacing _ with : (hierarchy separator). Double underscore __ is first collapsed to single _ before the mapping.
HOST_URLS -> host:urls
SERILOG_minimumLevel -> serilog:minimumLevel
serilog:
minimumLevel: Information # Verbose | Debug | Information | Warning | Error | Fatal
override:
System: Error
Microsoft: Error
Environment variables:
SERILOG_minimumLevel=Information
SERILOG_OVERRIDE_SYSTEM=Error
SERILOG_OVERRIDE_MICROSOFT=Error
CorsPolicy:
origins:
- "https://example.com"
methods:
- "GET"
- "POST"
headers:
- "*"
exposedHeaders:
- "*"
If any of origins, methods, headers, or exposedHeaders are not specified, they default to ["*"].
ipRateLimiting:
enableEndpointRateLimiting: true
generalRules:
- endpoint: "*"
period: "1s"
limit: 50
ipRateLimitPolicies: {}
Refer to AspNetCoreRateLimit documentation for the full schema.
When telemetry:endpoint is configured, traces, metrics, and logs are exported via OTLP. Log messages are enriched with SpanId and TraceId.
Use telemetry:name to explicitly set the service name used by OpenTelemetry resources for traces, metrics, and logs.
telemetry:
name: Dosaic.Example.Service # optional OpenTelemetry service name
endpoint: http://localhost:4317 # OTLP endpoint
protocol: grpc # grpc | http/protobuf
headers:
- name: Authorization
value: "Bearer <token>"
Without telemetry:endpoint, only the Prometheus scraping endpoint (/metrics) is active.
Metrics instrumentation (always active):
Meters (*) plus the shared Dosaic meter (Tracing.SourceName)Tracing instrumentation (requires telemetry:endpoint):
Dosaic ActivitySource (Tracing.SourceName) — emit your own spans with Tracing.StartActivity(...); see | Endpoint | Tags filtered |
|---|---|
GET /health/liveness |
liveness |
GET /health/readiness |
readiness |
Both endpoints return a JSON body:
{
"status": "Healthy",
"totalDuration": "00:00:00.012",
"entries": [
{
"name": "api",
"status": "Healthy",
"description": null,
"tags": ["liveness"],
"duration": "00:00:00.001",
"exceptionMessage": null
}
]
}
Built-in liveness checks registered automatically:
| Check | Description |
|---|---|
api |
Always healthy — confirms the process is running |
disk_space |
Checks free space on all drives |
memory |
Asserts allocated memory is below 2 GB |
Plugins can contribute additional checks via IPluginHealthChecksConfiguration.ConfigureHealthChecks().
Custom checks can also be auto-discovered by implementing IHealthCheck and annotating the class with [HealthCheck("name", ...tags)].
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.2.34 | 53 | 6/10/2026 |
| 1.2.33 | 65 | 6/2/2026 |
| 1.2.31 | 67 | 5/28/2026 |
| 1.2.30 | 78 | 5/7/2026 |
| 1.2.29 | 60 | 5/5/2026 |
| 1.2.28 | 74 | 4/30/2026 |
| 1.2.27 | 59 | 4/29/2026 |
| 1.2.26 | 58 | 4/29/2026 |
| 1.2.25 | 82 | 4/27/2026 |
| 1.2.24 | 71 | 4/21/2026 |
| 1.2.23 | 77 | 4/14/2026 |
| 1.2.22 | 74 | 4/10/2026 |
| 1.2.21 | 62 | 4/10/2026 |
| 1.2.20 | 72 | 4/10/2026 |
| 1.2.19 | 64 | 4/9/2026 |
| 1.2.18 | 78 | 4/2/2026 |
| 1.2.17 | 75 | 4/1/2026 |
| 1.2.16 | 79 | 4/1/2026 |
| 1.2.15 | 71 | 3/31/2026 |
| 1.2.14 | 70 | 3/30/2026 |