Blazor 服务器方法调用和执行详细信息

Blazor Server Method Call & Execution Details

我正在关注 this Blazor Server Counter Increment example

具体代码示例如下

我有三个问题:

1 - 单击按钮后对 IncrementCount 的调用是否通过 SignalR 发生?

2 - IncrementCount 的执行是否发生在服务器上? (与在浏览器中相反)

3 - 如果是通过 SignalR - 我如何才能看到 "the call"(请求)是使用 Chrome 开发人员工具发出的?我查看了“网络”选项卡,但看不到任何 activity。查看屏幕截图:

代码示例:

@page "/counter"

<h1>Counter</h1>

<p>Current count: @currentCount</p>

<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>

@code {
    private int currentCount = 0;

    private void IncrementCount()
    {
        currentCount++;
    }
}

使用 Blazor 服务器

1 - 是的,它通过 SignalR
发生 2 - 是的,它 运行 在服务器上
3 - 如果您想在浏览器开发工具中查看 Http 请求,SignalR 默认使用 websoket,configure SignalR transport to use long pooling
或者使用firefox,可以使用Firefox’s New WebSocket Inspecto

使用 Blazor WASM

1 - 不,它在浏览器上执行
2 - 不,它在浏览器上执行
3 - 没有请求,但你可以 debug using Visual Studio breakpoint 自 3.1-preview4

对于第 3 部分,在 chrome 100.0.4896.75 上,只需 select“网络 -> 全部”