Skip to content

Throw informative exception when Input Controls are not surrounded by EditForm #27804

@amdav

Description

@amdav

This is obviously a minor issue, but a NullReferenceException is thrown in the scenario (rather than something more useful), and a new user learning Blazor user would probably have no way to debug this. We need a more useful exception to be thrown (I was in Debug mode as well, and there also was no inner exception).

The scenario is using the Blazor Input controls (InputText, etc) without wrapping them with the EditForm. In this case, when in the default ServerPrerendering mode, the NullReferenceException breaks to this line below in the _Host.cshtml file:

<component type="typeof(App)" render-mode="ServerPrerendered" />

Obviously an exception is being thrown during prerendering (due to the code bug), but I cannot see how a new user learning Blazor would be able to figure out what the bug is. The framework needs to throw a more informative exception here to help new users.

Without PreRendering, the error is clear. If this is a more general issue (where PreRendering causes NullReferenceExceptions to be thrown), we need to provide as helpful diagnostics as possible due to ServerPrerendering being the default.

Metadata

Metadata

Assignees

No one assigned

    Labels

    DoneThis issue has been fixedaffected-mediumThis issue impacts approximately half of our customersarea-blazorIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.component ecosystemIndicates an issue which also has impact on 3rd party component ecosystemfeature-blazor-builtin-componentsFeatures related to the built in components we ship or could ship in the futurereevaluateWe need to reevaluate the issue and make a decision about itseverity-minorThis label is used by an internal tool

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions