Closed
Description
Summary
If a null
value is supplied as a parameter to a render mode boundary component during static SSR, and the SSR'd component is matched up with an existing interactive root component, a NullReferenceException
gets thrown by the framework.
Steps to reproduce
- Create a Blazor Web App with Server interactivity
- Define a component (
MyComponent.razor
):@inject NavigationManager NavigationManager <button @onclick="@(() => NavigationManager.Refresh())">Refresh</button> @code { [Parameter] public string? Value { get; set; } }
- Render the component from
Home.razor
and supply the valuenull
for theValue
parameter:<MyComponent Value="@null" @rendermode="InteractiveServer" />
- Run the app
- Click the button labeled "Refresh"
- Observe that an exception gets thrown and the circuit gets terminated
Relevant output
Stack trace:
Microsoft.AspNetCore.Components.Server.dll!Microsoft.AspNetCore.Components.WebRootComponentParameters.DefinitelyEquals(Microsoft.AspNetCore.Components.WebRootComponentParameters other) Line 43
at Microsoft.AspNetCore.Components\WebRootComponentParameters.cs(43)
Microsoft.AspNetCore.Components.Server.dll!Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer.WebRootComponentManager.WebRootComponent.UpdateAsync(Microsoft.AspNetCore.Components.Server.Circuits.RemoteRenderer renderer, System.Type newComponentType, Microsoft.AspNetCore.Components.ComponentMarkerKey? newKey, Microsoft.AspNetCore.Components.WebRootComponentParameters newParameters) Line 245
at Microsoft.AspNetCore.Components.Server.Circuits\RemoteRenderer.cs(245)
.
.
.
Proposed fix
Update WebRootComponentParameters
to account for the possibility that the parameter values are null
rather than being valid JsonElement
s.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done