'Web Assembly :: Control <head> content in a Razor component (InvalidOperationException)
For a WASM project, I'm trying to have the CSS be downloaded when the site binaries change.
I'm trying to follow this post I found here: https://stackoverflow.com/a/71228054/18462839
, which basically adds:
<HeadContent>
<link href="css/app.css?@(Configuration["BuildNumber"])" rel="stylesheet" />
in App.razor, and this:
builder.RootComponents.Add<HeadOutlet>("head::after");
in Program.cs
It seems to work, but I get an Exception for Title and Head:
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: There is already a subscriber to the content 'title'.
System.InvalidOperationException: There is already a subscriber to the content 'title'.
at Microsoft.AspNetCore.Components.Sections.SectionRegistry.Subscribe(String name, ISectionContentSubscriber subscriber)
at Microsoft.AspNetCore.Components.Sections.SectionOutlet.Microsoft.AspNetCore.Components.IComponent.SetParametersAsync(ParameterView parameters)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.SupplyCombinedParameters(ParameterView directAndCascadingParameters)
crit: Microsoft.AspNetCore.Components.WebAssembly.Rendering.WebAssemblyRenderer[100]
Unhandled exception rendering component: There is already a subscriber to the content 'head'.
System.InvalidOperationException: There is already a subscriber to the content 'head'.
at Microsoft.AspNetCore.Components.Sections.SectionRegistry.Subscribe(String name, ISectionContentSubscriber subscriber)
at Microsoft.AspNetCore.Components.Sections.SectionOutlet.Microsoft.AspNetCore.Components.IComponent.SetParametersAsync(ParameterView parameters)
at Microsoft.AspNetCore.Components.Rendering.ComponentState.SupplyCombinedParameters(ParameterView directAndCascadingParameters)
Are there some code fragments I'm missing here?;)
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
