diff --git a/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/SessionMiddleware.cs b/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/SessionMiddleware.cs index 08ea7ae084..7d6e6b5f7e 100644 --- a/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/SessionMiddleware.cs +++ b/src/Microsoft.AspNetCore.SystemWebAdapters.CoreServices/SessionMiddleware.cs @@ -56,11 +56,12 @@ private async Task ManageStateAsync(HttpContextCore context, ISessionStateFeatur { await _next(context); - using var cts = new CancellationTokenSource(CommitTimeout); - if (!details.IsReadOnly) { - await state.CommitAsync(cts.Token); + using var cts = new CancellationTokenSource(CommitTimeout); + using var linked = CancellationTokenSource.CreateLinkedTokenSource(cts.Token, context.RequestAborted); + + await state.CommitAsync(linked.Token); } } finally