![]() |
VOOZH | about |
dotnet add package CShells.AspNetCore --version 0.0.28
NuGet\Install-Package CShells.AspNetCore -Version 0.0.28
<PackageReference Include="CShells.AspNetCore" Version="0.0.28" />
<PackageVersion Include="CShells.AspNetCore" Version="0.0.28" />Directory.Packages.props
<PackageReference Include="CShells.AspNetCore" />Project file
paket add CShells.AspNetCore --version 0.0.28
#r "nuget: CShells.AspNetCore, 0.0.28"
#:package CShells.AspNetCore@0.0.28
#addin nuget:?package=CShells.AspNetCore&version=0.0.28Install as a Cake Addin
#tool nuget:?package=CShells.AspNetCore&version=0.0.28Install as a Cake Tool
ASP.NET Core integration for CShells providing middleware and shell resolution based on HTTP context.
This package provides ASP.NET Core middleware, shell resolution strategies, and extensions for building multi-tenant web applications with CShells.
MapShells() extension - Automatically register endpoints from all shell featuresdotnet add package CShells
dotnet add package CShells.AspNetCore
using CShells.AspNetCore.Features;
using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Routing;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
[ShellFeature("Weather", DisplayName = "Weather API")]
public class WeatherFeature : IWebShellFeature
{
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IWeatherService, WeatherService>();
}
public void MapEndpoints(IEndpointRouteBuilder endpoints, IHostEnvironment? environment)
{
endpoints.MapGet("weather", (IWeatherService weatherService) =>
weatherService.GetForecast());
}
}
{
"CShells": {
"Shells": {
"Default": {
"Features": { "Weather": {} },
"Configuration": {
"WebRouting": {
"Path": ""
}
}
},
"Admin": {
"Features": { "Admin": {} },
"Configuration": {
"WebRouting": {
"Path": "admin",
"RoutePrefix": "api/v1"
}
}
}
}
}
}
Simple setup:
var builder = WebApplication.CreateBuilder(args);
// Register CShells from configuration
builder.AddShells();
var app = builder.Build();
// Configure middleware and endpoints for all shells
app.MapShells();
app.Run();
Explicit feature assembly selection:
Use From* members to select discovery sources, and WithAssemblyProvider(...) when attaching a provider that contributes assemblies.
var builder = WebApplication.CreateBuilder(args);
builder.AddShells(cshells =>
{
cshells.WithConfigurationProvider(builder.Configuration);
cshells.FromAssemblies(typeof(Program).Assembly);
cshells.FromHostAssemblies();
});
var app = builder.Build();
app.MapShells();
app.Run();
If you do not call an assembly-source method, CShells uses the same host-derived feature assembly set as the default discovery behavior. Once you call FromAssemblies(...), FromHostAssemblies(), or WithAssemblyProvider(...), discovery switches to explicit provider mode and uses only the assemblies contributed by those appended providers.
Advanced setup with custom resolvers:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddCShellsAspNetCore(cshells =>
{
cshells.WithConfigurationProvider(builder.Configuration);
cshells.WithWebRoutingResolver(options =>
{
options.ExcludePaths = new[] { "/api", "/health" };
options.HeaderName = "X-Tenant-Id";
});
});
var app = builder.Build();
app.MapShells();
app.Run();
Shells are resolved based on the URL path prefix:
{
"Configuration": {
"WebRouting": {
"Path": "admin"
}
}
}
Requests to /admin/* will be routed to this shell.
Configure shells to respond to specific hostnames:
{
"Configuration": {
"WebRouting": {
"Host": "admin.example.com"
}
}
}
Apply a route prefix to all endpoints in a shell:
{
"Configuration": {
"WebRouting": {
"Path": "tenant1",
"RoutePrefix": "api/v1"
}
}
}
With this configuration, an endpoint mapped at weather will be accessible at /tenant1/api/v1/weather.
Implement IShellResolver for custom resolution logic:
public class CustomShellResolver : IShellResolver
{
public Task<string?> ResolveShellIdAsync(HttpContext context)
{
// Custom logic to determine shell ID from HTTP context
var shellId = context.Request.Headers["X-Tenant-Id"].FirstOrDefault();
return Task.FromResult(shellId);
}
}
builder.Services.AddCShellsAspNetCore(cshells =>
{
cshells.WithResolver<CustomShellResolver>();
});
Configure routing behavior:
builder.Services.AddCShellsAspNetCore(cshells =>
{
cshells.WithWebRoutingResolver(options =>
{
// Exclude paths from shell resolution
options.ExcludePaths = new[] { "/api", "/health", "/swagger" };
// Use custom header for tenant ID
options.HeaderName = "X-Tenant-Id";
// Configure default shell
options.DefaultShell = "Default";
});
});
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 is compatible. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. 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. |
Showing the top 2 NuGet packages that depend on CShells.AspNetCore:
| Package | Downloads |
|---|---|
|
CShells.FastEndpoints
FastEndpoints integration for CShells. Provides a shell feature that automatically discovers and registers FastEndpoints from all enabled features. Reference this package in your host application to enable FastEndpoints support. |
|
|
CShells.AspNetCore.Testing
Testing helpers for CShells ASP.NET Core integration. Provides utilities for integration tests, including shell initialization waiter for ensuring shells are fully loaded before test execution. |
Showing the top 1 popular GitHub repositories that depend on CShells.AspNetCore:
| Repository | Stars |
|---|---|
|
elsa-workflows/elsa-core
The Workflow Engine for .NET
|
| Version | Downloads | Last Updated |
|---|---|---|
| 0.0.28 | 172 | 6/12/2026 |
| 0.0.27 | 134 | 6/12/2026 |
| 0.0.26 | 132 | 6/12/2026 |
| 0.0.25 | 134 | 6/11/2026 |
| 0.0.24 | 264 | 5/15/2026 |
| 0.0.23 | 134 | 5/15/2026 |
| 0.0.22 | 133 | 5/14/2026 |
| 0.0.21 | 139 | 5/12/2026 |
| 0.0.20 | 144 | 5/8/2026 |
| 0.0.19 | 139 | 5/6/2026 |
| 0.0.18 | 135 | 5/2/2026 |
| 0.0.17 | 148 | 4/29/2026 |
| 0.0.16 | 145 | 4/27/2026 |
| 0.0.15 | 137 | 4/27/2026 |
| 0.0.14 | 478 | 4/20/2026 |
| 0.0.13 | 138 | 4/17/2026 |
| 0.0.12 | 206 | 3/16/2026 |
| 0.0.11 | 251 | 2/28/2026 |
| 0.0.10 | 147 | 2/24/2026 |
| 0.0.9 | 409 | 2/15/2026 |