Skip to content

SupplyParameterFromForm doesn't work when there's a referenced class with an abstract member #65002

@neoGeneva

Description

@neoGeneva

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

I have a form that's [SupplyParameterFromForm] to bind a class. That class has a property that references another class which is abstract and has abstract members.

When attempting to submit the form the class is not bound, no validation errors are shown, and no exception is thrown. Using the debugger I discovered an error value deep in the EditContext: No method 'PushPrefix' on type 'Microsoft.AspNetCore.Components.Endpoints.FormMapping.FormDataReader' is compatible with the supplied arguments.

I can use [IgnoreDataMember] on the property to work around the issue for myself, though it was quite a pain figuring out what the issue even was.

Ideally when an exception is thrown internally then there should be more visibility to it, either a runtime error or something in the validation messages. Also, it would be good to have a specific error for this case letting people know they can't bind to class with abstract members.

Expected Behavior

The form should be bound or an exception should be thrown

Steps To Reproduce

Example repo is here: https://github.com/neoGeneva/BlazorBindingIssue

If you run the project and submit the form it'll show you the error which I've used reflection to dig out, there might be a better way to get the issue but I'm new to Blazor and couldn't find one.

If you update BindingModel.cs to remove the reference to AbstractModel then rerun the project the there error is gone and the form binds correctly.

Exceptions (if any)

No response

.NET Version

10.0.100

Anything else?

No response

Metadata

Metadata

Assignees

Labels

area-blazorIncludes: Blazor, Razor Components

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions