-
Notifications
You must be signed in to change notification settings - Fork 10.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
EditForm requires either a Model parameter, or an EditContext parameter, please provide one of these. #55701
Comments
"/Account/Login" will be in Static Server Mode and that is why MudBlazor and its UI Controls will not work. Try using HTML5 controls or in-built Blazor Input Controls such as InputText Also inside OnInitializedAsync use Input ??= new(); //This will re-initialize the Model in case of Null Note: MudBlazor requires InteractiveServerRenderMode |
Thank you - as noted in my question the following results in the page being displayed briefly then the page becomes blank and the text "Not found" is displayed. Same behavior if The text "Not found" does not exist anywhere in my .sln. Is this a dotnet error? There are no errors in the browser console and all network calls complete normally. Where does the error "Not found" come from? It is not MudBlazor as I have commented out all html on the page.
} |
The "Not found" behavior can be reproduced as follows: Create a new Blazor app with individual account auth, render mode = Auto Change this line in server project App.razor:
Run the app and click Login on the nav menu Result: F12 in the browser and refresh, note no 404 errors or console errors. What is Blazor looking for that is not found? |
This is how you can avoid the Lines 22 to 30 in d6c333e
Please note, that all the account pages share this logic (through the common layout), to force rendering on the server. |
I'm sorry I don't understand this. If you follow the steps to reproduce that I provided above the account pages do not render. |
I told @mkArtakMSFT to link to the
It comes from here in the You'll notice that when you choose the "Global" interactivity location when creating a new Blazor project, it puts If you create a Blazor project with the default "Per page/component" interactivity location, the Unfortunately, even if the The purpose of the If you want to use interactive rendering for your account pages, you'll probably want to set up separate API endpoints for things like registration and login which you can trigger via a new
In some cases, you might be able to leave the account pages as non-interactive and make only the MudBlazor components contained within interactive (e.g. If you don't actually need interactive account components, and you just need the account components to match your MudBlazor style, I recommend copying the CSS classes from the MudBlazor components to your own components that don't require interactivity. Does this help resolve your issue? |
Hi @sam-wheat. We have added the "Needs: Author Feedback" label to this issue, which indicates that we have an open question for you before we can take further action. This issue will be closed automatically in 7 days if we do not hear back from you by then - please feel free to re-open it if you come back to this issue after that time. |
@halter73 Thank you for the great explanation I'm going to have read this a couple of times. I hope this makes its way into the documentation. |
Hey @sam-wheat , I'm having the same issue and in my case, if I inspect the HTML elements in the form, the MudTextField component is not creating the input |
I am very sorry I am unable to figure this out on my own.
Here are links I have found that have not assisted me in resolving this:
https://learn.microsoft.com/en-us/aspnet/core/blazor/forms/binding?view=aspnetcore-8.0
https://learn.microsoft.com/en-us/aspnet/core/blazor/components/render-modes?view=aspnetcore-8.0
https://stackoverflow.com/questions/67641707/editform-requires-either-a-model-parameter-or-an-editcontext-parameter
dotnet/AspNetCore.Docs#14869
#51420 // supplying formname as shown here does not work.
#43400 // applies to Maui however I am newing the model as suggested by the ticket.
Server side
App.razor
:The route for the form above is "/Account/Login". As shown below when I change the render mode to
InteractiveServerRenderMode
the page is not found.When I remove
[SupplyParameterFromForm]
the form submits however the values are empty strings (not bound to user input).Error message:
The text was updated successfully, but these errors were encountered: