Repository navigation
Register core output caching services in Redis output cache integration - #21222
Merged
Ankit Jain (radical) merged 1 commit intoOct 30, 2026
Merged
Conversation
Curllog (curllog)
requested review from
Eric Erhardt (eerhardt),
Ankit Jain (radical) and
Sébastien Ros (sebastienros)
as code owners
October 20, 2026 21:11
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 21222Or
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 21222" |
Contributor
Author
|
@microsoft-github-policy-service agree |
1 task done
Contributor
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
Contributor
|
Retrying the failed CI jobs for this pull request from the CI run attempt. The rerun is being tracked in the rerun attempt. |
4 of 14 tasks
Ankit Jain (radical)
approved these changes
Oct 30, 2026
Ankit Jain (radical)
enabled auto-merge (squash)
October 30, 2026 21:35
Ankit Jain (radical)
merged commit Oct 30, 2026
57971d4
into
microsoft:main
752 of 764 checks passed
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.
Register core output caching services in Redis output cache integration
Fixes #21221
Problem
On .NET 11, an app that uses Aspire's Redis output caching together with
app.UseOutputCache()crashes at startup:This affects the Aspire Starter template's Web frontend as soon as it targets
net11.0.AddRedisOutputCache,AddKeyedRedisOutputCacheandAddRedisClientBuilder(...).WithOutputCache()only registered the RedisIOutputCacheStore(throughAddStackExchangeRedisOutputCache). They never calledAddOutputCache(). In .NET 11,OutputCacheMiddlewarerequiresIOutputCachePolicyProvider, which onlyAddOutputCache()registers, so the middleware can't be created.Fix
AddRedisOutputCacheCore, which all three public APIs call, now callsbuilder.Services.AddOutputCache()before registering the Redis store.AddOutputCache()usesTryAdd*, so apps that already call it themselves are unaffected.AddOutputCache()registers its in-memoryIOutputCacheStorewithTryAdd, so it doesn't replace the Redis store. The existingAddsRedis*OutputCacheCorrectlytests still pass and check this.AddOutputCache()exists on all supported TFMs. No public API changes.Tests
I added
RegistersOutputCachePolicyProvidertoAspireRedisOutputCacheExtensionsTests.cs, a[Theory]that covers all three entry points (plain,keyed,builder). Each case checks thatIOutputCachePolicyProvideris registered.The test is wrapped in
#if NET11_0_OR_GREATER, becauseIOutputCachePolicyProviderdoesn't exist before .NET 11. The repo already uses the same pattern elsewhere, e.g.tests/Shared/Processes/ProcessTestFixture.cs. It doesn't need Redis or Docker; it only checks DI registrations.Before the fix (net11.0):
After the fix (net11.0):
How to test