diff --git a/src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/RequestExtensions.cs b/src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/RequestExtensions.cs
new file mode 100644
index 0000000000..8f6302f703
--- /dev/null
+++ b/src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/RequestExtensions.cs
@@ -0,0 +1,37 @@
+// Licensed to the .NET Foundation under one or more agreements.
+// The .NET Foundation licenses this file to you under the MIT license.
+
+using System.Web;
+
+namespace Microsoft.AspNetCore.SystemWebAdapters;
+
+internal static class RequestExtensions
+{
+ ///
+ /// Gets the request stream. If it has already been retrieved, it will be in whatever
+ /// it was already accessed. Otherwise, it will get a bufferless version via .
+ ///
+ /// The request
+ ///
+ public static Stream GetInputStream(this HttpRequestBase request)
+ {
+ // If a call has been made to InputStream, we must use that. It is seekable, so we need to rewind it to the beginning
+ if (request.ReadEntityBodyMode == ReadEntityBodyMode.Classic)
+ {
+ var stream = request.InputStream;
+ stream.Position = 0;
+ return stream;
+ }
+
+ // If a call has been made to GetBufferedInputStream, we must use that. It is seekable, so we need to rewind it to the beginning
+ if (request.ReadEntityBodyMode == ReadEntityBodyMode.Buffered)
+ {
+ var stream = request.GetBufferedInputStream();
+ stream.Position = 0;
+ return stream;
+ }
+
+ // Otherwise, let's attempt to get a bufferless version since we don't need it buffered
+ return request.GetBufferlessInputStream();
+ }
+}
diff --git a/src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/SessionState/RemoteSession/StoreSessionStateHandler.cs b/src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/SessionState/RemoteSession/StoreSessionStateHandler.cs
index fc860fc808..76f3671e11 100644
--- a/src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/SessionState/RemoteSession/StoreSessionStateHandler.cs
+++ b/src/Microsoft.AspNetCore.SystemWebAdapters.FrameworkServices/SessionState/RemoteSession/StoreSessionStateHandler.cs
@@ -43,7 +43,7 @@ public async Task ProcessRequestAsync(HttpContextBase context)
}
else
{
- using var content = context.Request.GetBufferlessInputStream();
+ using var content = context.Request.GetInputStream();
var result = await _cache.SaveAsync(sessionId, content, context.Response.ClientDisconnectedToken);
if (result is SessionSaveResult.Success)