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

How does the RenderMode.InteractiveAuto work in .Net 8 Blazor Web Apps?

$
0
0

I'm trying to understand the render mode "RenderMode.InteractiveAuto".Everything works until I visit a page with the render mode "RenderMode.InteractiveServer", after that all my pages stay in render mode server.

I added this code : OperatingSystem.IsBrowser() ? "WASM":"SERVEUR" for display in which mode my page is render.

For example with the sample project "Blazor Web App", I duplicate the counter but I set the render mode to : @rendermode InteractiveServerMy Visual Studio files explorer

There is the code of Counter.razor :

@page "/counter"@rendermode InteractiveAuto<PageTitle>Counter</PageTitle><h1>Counter</h1><p role="status">Current count: @currentCount</p><button class="btn btn-primary" @onclick="IncrementCount">Click me</button><p>@(OperatingSystem.IsBrowser() ? "WASM" : "SRV")</p>@code {    private int currentCount = 0;    private void IncrementCount()    {        currentCount++;    }}

There is the code of CounterServeur.razor :

@page "/counterSRV"@rendermode InteractiveServer<PageTitle>Counter</PageTitle><h1>Counter</h1><p role="status">Current count: @currentCount</p><button class="btn btn-primary" @onclick="IncrementCount">Click me</button><p>@(OperatingSystem.IsBrowser() ? "WASM" : "SRV")</p>@code {    private int currentCount = 0;    private void IncrementCount()    {        currentCount++;    }}

When I launch the application and then I go to Counter.razor (with NavMenu), my page is in WASM mode (it's ok) :Screenshot of the result

After that I go to CounterServeur.razor (with NavMenu), my page is in SERVER mode (it's ok) :Screenshot of the result

And then when I go back to Counter.razor (with NavMenu), my page is in SERVER mode and not in WASM mode :Screenshot of the result


Viewing all articles
Browse latest Browse all 4839

Trending Articles



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