最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

.net - use InteractiveWebAssembly in Blazor Web App - Stack Overflow

programmeradmin2浏览0评论

I created project from this template (.NET 8):

And I want to use InteractiveWebAssembly in Counter.razor page.

I add modification in Program.cs:

builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents() 
    .AddInteractiveWebAssemblyComponents();

and:

app.MapRazorComponents<App>()
    .AddInteractiveServerRenderMode()
    .AddInteractiveWebAssemblyRenderMode();  

and on Counter.razor replaced @rendermode InteractiveServer to @rendermode InteractiveWebAssembly

But after this counter stopped to work, debugger never go to IncrementCount() method.

What did you miss, do I need other modifications in the project?

I created project from this template (.NET 8):

And I want to use InteractiveWebAssembly in Counter.razor page.

I add modification in Program.cs:

builder.Services.AddRazorComponents()
    .AddInteractiveServerComponents() 
    .AddInteractiveWebAssemblyComponents();

and:

app.MapRazorComponents<App>()
    .AddInteractiveServerRenderMode()
    .AddInteractiveWebAssemblyRenderMode();  

and on Counter.razor replaced @rendermode InteractiveServer to @rendermode InteractiveWebAssembly

But after this counter stopped to work, debugger never go to IncrementCount() method.

What did you miss, do I need other modifications in the project?

Share Improve this question asked Feb 7 at 16:09 AlexanAlexan 8,63714 gold badges82 silver badges106 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 1

The default template does not include WebAssembly functionality.

To enable WASM, any code that runs in the browser must be placed in a separate project.

Here’s the recommended project structure for enabling WASM interactivity:

You can set this up easily using the --interactivity WebAssembly option when generating the project (or the corresponding switches in your IDE):

dotnet new blazor -o WasmTest2 --interactivity WebAssembly

Note: It's bit confusing, because --interactivity WebAssembly means "also with wasm", not "wasm only". For wasm only there is separated dontet new blazorwasm template.

发布评论

评论列表(0)

  1. 暂无评论