-
Notifications
You must be signed in to change notification settings - Fork 10.7k
Throw informative exception when Input Controls are not surrounded by EditForm #27804
Copy link
Copy link
Closed
Closed
Copy link
Labels
DoneThis issue has been fixedThis issue has been fixedaffected-mediumThis issue impacts approximately half of our customersThis issue impacts approximately half of our customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.component ecosystemIndicates an issue which also has impact on 3rd party 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 futureFeatures related to the built in components we ship or could ship in the futurereevaluateWe need to reevaluate the issue and make a decision about itWe need to reevaluate the issue and make a decision about itseverity-minorThis label is used by an internal toolThis label is used by an internal tool
Milestone
Metadata
Metadata
Assignees
Labels
DoneThis issue has been fixedThis issue has been fixedaffected-mediumThis issue impacts approximately half of our customersThis issue impacts approximately half of our customersarea-blazorIncludes: Blazor, Razor ComponentsIncludes: Blazor, Razor ComponentsbugThis issue describes a behavior which is not expected - a bug.This issue describes a behavior which is not expected - a bug.component ecosystemIndicates an issue which also has impact on 3rd party 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 futureFeatures related to the built in components we ship or could ship in the futurereevaluateWe need to reevaluate the issue and make a decision about itWe need to reevaluate the issue and make a decision about itseverity-minorThis label is used by an internal toolThis label is used by an internal tool
Type
Fields
Give feedbackNo fields configured for issues without a type.
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:
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.