Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using System.Threading;
using System.Threading.Tasks;
using System.Web.SessionState;
using Microsoft.AspNetCore.Http;
Expand All @@ -22,6 +23,8 @@ internal partial class SessionMiddleware
[LoggerMessage(EventId = 1, Level = LogLevel.Warning, Message = "Creating session on demand by synchronously waiting on a potential asynchronous connection")]
private partial void LogOnDemand();

private readonly TimeSpan CommitTimeout = TimeSpan.FromMinutes(1);

public SessionMiddleware(RequestDelegate next, ILogger<SessionMiddleware> logger)
{
_next = next;
Expand Down Expand Up @@ -56,7 +59,9 @@ private async Task ManageStateAsync(HttpContextCore context, SessionAttribute me
try
{
await _next(context);
await state.CommitAsync(context.RequestAborted);

using var cts = new CancellationTokenSource(CommitTimeout);
await state.CommitAsync(cts.Token);
}
finally
{
Expand Down