dotnet / aspnetcore

ASP.NET Core is a cross-platform .NET framework for building modern cloud-based web applications on Windows, Mac, or Linux.
https://asp.net
MIT License
35.33k stars 9.97k forks source link

Placing EditForm in Section Content Component Causes run-time error #56635

Open htmlsplash opened 3 months ago

htmlsplash commented 3 months ago

Is there an existing issue for this?

Describe the bug

Context Balzor Web App, Static SSR by default

If you have an interactive server page and you place an edit form in the Section Content component, this will produce the following error when you submit the form

Returned Error message displayed in the browser:

The POST request does not specify which form is being submitted. To fix this, ensure

elements have a @formname attribute with any unique value, or pass a FormName parameter if using .

Code

`

` The Section outlet is in a sidebar component that is inside a layout component. `` Debugged Behavior: The browser performs full postback to the server instead of using the open WebSocket. ### Expected Behavior The form should submit and the event handler for the edit form's OnSubmit should run. I verified this if I take the Edit Form outside the Section Content component. The Edit form placed inside section content component does behave correctly on a static SSR page. ### Steps To Reproduce _No response_ ### Exceptions (if any) _No response_ ### .NET Version _No response_ ### Anything else? _No response_
htmlsplash commented 3 months ago

I don't have a repo, and I included instructions to reproduce the problem. These instructions are simple enough to be followed.

javiercn commented 3 months ago

@htmlsplash thanks for contacting us.

Unfortunately, we don't think that's the case. In order for us to troubleshoot an issue like this, we need a repro. We ask for a repro project because even though you might think your indications are enough, there are many details that you might not deem relevant but that might actually be important. A repro project is the only way we have to be sure we don't miss anything.

htmlsplash commented 3 months ago

@javiercn I was not aware that you were not able to reproduce the problem. In this case, hang on, let me try to create a project for testing.

htmlsplash commented 3 months ago

Here is the link to the public repo you requested:

https://github.com/htmlsplash/BlazorWebAppTest

Run the project, select "EditForm Test" from the left side bar to go to the test page.

Once on the "EditFormInsideSectionTest" page, populate input fields in the sidebar and click the submit button to submit the form. You will get the aforementioned error.

If you edit the EditFormInsideSectionTest component and move the EditForm outside the section content, so it is on the page, not in the sidebar, the form submits fine and you get submitted fields printed to the console.