Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Blazor server hosted: Why I can't see any network request while debugging?

I've started to learn Blazor. I create a new "Blazor Server App" project on VS 2019 and after creation, just click debug and my project runs fine. The default template has a "Fetch Data" page that has a logic to retrieve data from server side:

forecasts = await ForecastService.GetForecastAsync(DateTime.Now);

I added a button to refresh data from server:

<button class="btn btn-primary" @onclick="OnInitializedAsync">Refresh</button>

And I have opened my Chrome Inspector and watching any network activity. But when I move on pages or on clicking Refresh button, all the logic works fine, but I don't see any new network activity. Only on first time page opening a WebSocket connection occurs.
Blazor documents say that it communicates by SignalR using WebSockets but I don't see anything.
Could you please describe this?

like image 325
Aliaaa Avatar asked Mar 11 '26 03:03

Aliaaa


1 Answers

Not only data fetch but every interaction is sent to the server. The messages are sent via the web socket not via separate network requests. Note that the fetching of the data happens on the server. In this case Blazor doesn't care how you fetch the data, from Blazor's point of view every interaction is a network message (via the web socket) and the response which is HTML is another message. If you request data or simply change CSS classes is irrelevant to the number of messages you will see enter image description here

like image 76
Stilgar Avatar answered Mar 14 '26 10:03

Stilgar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!