Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4148

How can I make .net 8.0 razor components, in a shared project, interactive?

$
0
0

I have a visual studio solution containing several blazor web application projects.Each of the applications has a requirement to use several identical components.I should like to place web assembly components in a shared project, add them as project references and include them in the _imports.razor file and include them on the pages of the various web applications.

I have placed the 'counter' component in the shared project and added it to a page:

<Counter @rendermode="InteractiveAuto"/>

But running the project gives me the following error:

InvalidOperationException: A component of type 'myawesomenamespace.Counter' has render mode 'InteractiveAutoRenderMode', but the required endpoints are not mapped on the server. When calling 'MapRazorComponents', add a call to 'AddInteractiveServerRenderMode'. For example, 'builder.MapRazorComponents<...>.AddInteractiveServerRenderMode()'

This line:

app.MapRazorComponents<web.components.App>().AddInteractiveWebAssemblyRenderMode().AddAdditionalAssemblies(typeof(wasm._imports).Assembly);

is present in the server Program.cs file.

If I exclude the '@rendermode="InteractiveAuto"' directive, the component renders but the button doesn't work.

Are interactive components in a shared project even possible?


Viewing all articles
Browse latest Browse all 4148

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>