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.36k stars 9.99k forks source link

Blazor WASM wrong error message #20051

Closed Julien-Marpault closed 4 years ago

Julien-Marpault commented 4 years ago

I get this error message with my EditForm:

blazor.webassembly.js:1 WASM: System.InvalidOperationException: EditForm requires a Model parameter, or an EditContext parameter, but not both.

The problem is I not defined a model neither a context.

javiercn commented 4 years ago

@JulienM28 thanks for contacting us.

Can you provide a minimal repro project that showcases the issue so that we can investigate?

Julien-Marpault commented 4 years ago

Here it is:

 <EditForm OnValidSubmit="async ()=>await SubmitAsync()">
                <DataAnnotationsValidator />

                <div class="input-group">
                    <InputTextOnInput class="border-bottom-dark" @bind-Value="ViewModel.SupplierName" required />
                    <ValidationMessage For="@(() => ViewModel.SupplierName)" />
                    <label>Raison sociale</label>
                </div>

                <div class="input-group">
                    <InputSiret class="border-bottom-dark" @bind-Value="ViewModel.SupplierSiret" />
                    @* <InputTextOnInput class="border-bottom-dark" @bind-Value="ViewModel.SupplierSiret" required /> *@
                    <ValidationMessage For="@(() => ViewModel.SupplierSiret)" />
                </div>

                <button class="btn btn-default btn-ok btn-fixed-br" disabled="@ViewModel.ValidationDisabled">Valider</button>
</EditForm>

In this case, instead of saying that I need a context or a model, th error message is saying : System.InvalidOperationException: EditForm requires a Model parameter, or an EditContext parameter, but not both.

It's not a big problem, but it may be confusing.

Thanks.

mkArtakMSFT commented 4 years ago

Thanks for sharing the details. We think the error message represents the problem correctly and we don't want to change that at the moment. If we hear similar confusion from other community members in the future, we will reconsider tweaking it then.