Repository navigation
fix(aspnetcore): begin the ambient tenant scope from a startup filter - #1240
Merged
Merged
Conversation
Getting Started and Strategies showed app.UseMultiTenant(), which no longer compiles now that only UseMultiTenant<TId>() exists. Also fix the UseMultiTenant<strinG>() typo and update the Introduction to .NET 11. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Match the SDK, target framework and CI test commands to the net11.0 solution, including the coverage flag CI passes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
AddHttpAmbientTenantScope() decorated IHttpContextFactory to begin the per-request scope. Replacing the default factory turns off ASP.NET Core's per-connection HttpContext reuse, so every request allocated a new HttpContext. Register a TenantScopeStartupFilter ahead of all other startup filters instead. Its middleware begins the scope at the very start of the pipeline, so the scope still covers middleware added before UseMultiTenant<TId>() or by other startup filters, and it is discarded when the middleware returns. The IHttpContextFactory is left untouched. TenantScopeHttpContextFactory was never released, so removing it is not a breaking change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cover that the ambient tenant scope begun by the startup filter is still active for Response.OnStarting callbacks and has ended before Response.OnCompleted callbacks run. The test for the removed IHttpContextFactory decorator covered when the scope ended, and nothing had replaced it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes ahead of the v11 release.
Per-request tenant scope (
fix(aspnetcore))AddHttpAmbientTenantScope()used to decorateIHttpContextFactoryto begin each request's ambient tenant scope. Replacing the default factory turns off ASP.NET Core's per-connectionHttpContextreuse, so every request allocated a newHttpContext.It now registers a
TenantScopeStartupFilterahead of all other startup filters. The filter's middleware begins the scope at the very start of the pipeline, so the scope still covers middleware added beforeUseMultiTenant<TId>()or by other startup filters. The scope is discarded when that middleware returns.IHttpContextFactoryis left untouched.TenantScopeHttpContextFactorywas never released, so removing it is not a breaking change. The AspNetCore, Configuration and Usage, Core Concepts, Generic Host and Getting Started docs now describe the new mechanism.Docs
app.UseMultiTenant(), which no longer compiles. Both now useUseMultiTenant<string>()to match theirAddMultiTenant<TenantInfo, string>()setup.UseMultiTenant<strinG>()typo in Configuration and Usage.net11.0, and its CI test commands now matchci.yml.Testing
dotnet build -p:ContinuousIntegrationBuild=true: 0 warnings, 0 errors.dotnet test: all pass (Core 331, AspNetCore 197, EFCore 159, Identity 91).🤖 Generated with Claude Code