Summary
The Request.Form shim (PR #532) currently only works in SSR mode because interactive Blazor Server has no HTTP POST all interactions flow through SignalR. This means Request.Form["field"] returns empty in interactive mode by design.
Proposal
Create a <WebFormsForm> Blazor component that bridges form submissions to the FormShim via JavaScript interop, enabling Request.Form to work in both SSR and interactive modes.
How it works
| Mode |
Flow |
| SSR |
form POST -> IFormCollection -> FormShim (works today) |
| Interactive |
WebFormsForm -> JS interop reads FormData -> SignalR -> populates FormShim (new) |
Implementation approach
WebFormsForm component wraps a <form> element
- JS interop reads
FormData from the DOM and sends key/value pairs to C#
FormShim.SetFormData() populates the shim from JS interop data
WebFormsPageBase integration wires the form to Request.Form
Migration story
<!-- Web Forms -->
<form runat="server">
<asp:TextBox ID="txtName" runat="server" />
</form>
<!-- Blazor with BWFC -->
<WebFormsForm>
<input type="text" name="txtName" />
</WebFormsForm>
@@code {
// Same code works in both SSR and interactive mode
string name = Request.Form["txtName"];
}
Acceptance criteria
Dependencies
Summary
The
Request.Formshim (PR #532) currently only works in SSR mode because interactive Blazor Server has no HTTP POST all interactions flow through SignalR. This meansRequest.Form["field"]returns empty in interactive mode by design.Proposal
Create a
<WebFormsForm>Blazor component that bridges form submissions to theFormShimvia JavaScript interop, enablingRequest.Formto work in both SSR and interactive modes.How it works
Implementation approach
WebFormsFormcomponent wraps a<form>elementFormDatafrom the DOM and sends key/value pairs to C#FormShim.SetFormData()populates the shim from JS interop dataWebFormsPageBaseintegration wires the form toRequest.FormMigration story
Acceptance criteria
<WebFormsForm>component renders a<form>elementFormDataon submit and sends to serverRequest.Form["field"]returns submitted values in interactive modeRequest.Form.GetValues("field")works for multi-value fieldsDependencies