Skip to content

Commit 8288dd2

Browse files
csharpfritzCopilot
andcommitted
fix: return interop form data over HttpContext in RequestShim.Form
In Blazor Server interactive circuits, HttpContext is available (from the SignalR WebSocket connection), but its Request.Form contains the WebSocket upgrade request data, not the interactive form submission. When SetFormData() has been called (WebFormsForm submit), the cached interop-backed FormShim must take priority. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent ea737c7 commit 8288dd2

1 file changed

Lines changed: 8 additions & 4 deletions

File tree

src/BlazorWebFormsComponents/RequestShim.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,13 @@ public FormShim Form
6767
{
6868
get
6969
{
70+
// If SetFormData() was called (WebFormsForm submit), return the cached
71+
// interop-backed shim even when HttpContext is available (Blazor Server
72+
// SignalR circuits always have an HttpContext, but its Request.Form is
73+
// from the original WebSocket upgrade, not the interactive form submit).
74+
if (_cachedFormShim != null)
75+
return _cachedFormShim;
76+
7077
if (_httpContext != null)
7178
{
7279
try
@@ -80,10 +87,7 @@ public FormShim Form
8087
}
8188
}
8289

83-
// Interactive mode: cache and reuse so SetFormData() persists
84-
if (_cachedFormShim != null)
85-
return _cachedFormShim;
86-
90+
// Interactive mode without prior SetFormData call
8791
if (!_formWarned)
8892
{
8993
_logger.LogWarning(

0 commit comments

Comments
 (0)