Skip to content

Commit 0fe9479

Browse files
authored
Minor updates to the Debug article (#33887)
1 parent ca00852 commit 0fe9479

File tree

1 file changed

+9
-61
lines changed

1 file changed

+9
-61
lines changed

aspnetcore/blazor/debug.md

Lines changed: 9 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,13 @@ Blazor Server: [`Microsoft.AspNetCore.Components.WebAssembly.Server`](https://ww
164164

165165
:::moniker-end
166166

167-
Standalone Blazor WebAssembly: [`Microsoft.AspNetCore.Components.WebAssembly.DevServer`](https://www.nuget.org/packages/Microsoft.AspNetCore.Components.WebAssembly.DevServer): Development server for use when building Blazor apps. Calls <xref:Microsoft.AspNetCore.Builder.WebAssemblyNetDebugProxyAppBuilderExtensions.UseWebAssemblyDebugging%2A?displayProperty=nameWithType> internally to add middleware for debugging Blazor WebAssembly apps inside Chromium developer tools.
167+
Standalone Blazor WebAssembly: [`Microsoft.AspNetCore.Components.WebAssembly.DevServer`](https://www.nuget.org/packages/Microsoft.AspNetCore.Components.WebAssembly.DevServer): Development server for use when building Blazor apps. Calls <xref:Microsoft.AspNetCore.Builder.WebAssemblyNetDebugProxyAppBuilderExtensions.UseWebAssemblyDebugging%2A> internally to add middleware for debugging Blazor WebAssembly apps inside Chromium developer tools.
168168

169169
:::moniker range="< aspnetcore-8.0"
170170

171171
Hosted Blazor WebAssembly:
172172

173-
* **:::no-loc text="Client":::** project: [`Microsoft.AspNetCore.Components.WebAssembly.DevServer`](https://www.nuget.org/packages/Microsoft.AspNetCore.Components.WebAssembly.DevServer): Development server for use when building Blazor apps. Calls <xref:Microsoft.AspNetCore.Builder.WebAssemblyNetDebugProxyAppBuilderExtensions.UseWebAssemblyDebugging%2A?displayProperty=nameWithType> internally to add middleware for debugging Blazor WebAssembly apps inside Chromium developer tools.
173+
* **:::no-loc text="Client":::** project: [`Microsoft.AspNetCore.Components.WebAssembly.DevServer`](https://www.nuget.org/packages/Microsoft.AspNetCore.Components.WebAssembly.DevServer): Development server for use when building Blazor apps. Calls <xref:Microsoft.AspNetCore.Builder.WebAssemblyNetDebugProxyAppBuilderExtensions.UseWebAssemblyDebugging%2A> internally to add middleware for debugging Blazor WebAssembly apps inside Chromium developer tools.
174174
* **:::no-loc text="Server":::** project: [`Microsoft.AspNetCore.Components.WebAssembly.Server`](https://www.nuget.org/packages/Microsoft.AspNetCore.Components.WebAssembly.Server): References an internal package ([`Microsoft.NETCore.BrowserDebugHost.Transport`](https://github.com/dotnet/runtime/blob/main/src/mono/nuget/Microsoft.NETCore.BrowserDebugHost.Transport/Microsoft.NETCore.BrowserDebugHost.Transport.pkgproj)) for assemblies that share the browser debug host.
175175

176176
:::moniker-end
@@ -187,43 +187,17 @@ The example in this section assumes that you've created a Blazor Web App with an
187187

188188
1. Open the app.
189189
1. Set a breakpoint on the `currentCount++;` line in the `Counter` component (`Pages/Counter.razor`) of the client project (`.Client`).
190-
1. Press <kbd>F5</kbd> to run the app in the debugger.
190+
1. With the server project selected in **Solution Explorer**, press <kbd>F5</kbd> to run the app in the debugger.
191191
1. In the browser, navigate to `Counter` page at `/counter`. Wait a few seconds for the debug proxy to load and run. Select the **Click me** button to hit the breakpoint.
192192
1. In Visual Studio, inspect the value of the `currentCount` field in the **Locals** window.
193193
1. Press <kbd>F5</kbd> to continue execution.
194194

195195
Breakpoints can also be hit in the server project in statically-rendered and interactively-rendered server-side components.
196196

197197
1. Stop the debugger.
198-
1. Add the following component to the server app. The component applies the Interactive Server render mode (`InteractiveServer`).
199-
200-
`Components/Pages/Counter2.razor`:
201-
202-
```razor
203-
@page "/counter-2"
204-
@rendermode InteractiveServer
205-
206-
<PageTitle>Counter 2</PageTitle>
207-
208-
<h1>Counter 2</h1>
209-
210-
<p role="status">Current count: @currentCount</p>
211-
212-
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
213-
214-
@code {
215-
private int currentCount = 0;
216-
217-
private void IncrementCount()
218-
{
219-
currentCount++;
220-
}
221-
}
222-
```
223-
224-
1. Set a breakpoint on the `currentCount++;` line in the `Counter2` component.
198+
1. In the server app, open the statically-rendered `Weather` component (`Components/Pages/Weather.razor`) and set a breakpoint anywhere in the `OnInitializedAsync` method.
225199
1. Press <kbd>F5</kbd> to run the app in the debugger.
226-
1. In the browser, navigate to `Counter2` page at `/counter-2`. Wait a few seconds for the debug proxy to load and run. Select the **Click me** button to hit the breakpoint.
200+
1. In the browser, navigate to the `Weather` page at `/weather`. Wait a few seconds for the debug proxy to load and run. Application execution stops at the breakpoint.
227201
1. Press <kbd>F5</kbd> to continue execution.
228202

229203
Breakpoints are **not** hit during app startup before the debug proxy is running. This includes breakpoints in the `Program` file and breakpoints in the [`OnInitialized{Async}` lifecycle methods](xref:blazor/components/lifecycle#component-initialization-oninitializedasync) of components that are loaded by the first page requested from the app.
@@ -241,35 +215,9 @@ The example in this section assumes that you've created a Blazor Web App with an
241215
Breakpoints can also be hit in the server project.
242216

243217
1. Stop debugging by selecting the **Stop** button or press <kbd>Shift</kbd>+<kbd>F5</kbd> on the keyboard.
244-
1. Add the following component to the server app. The component adopts the Interactive Server render mode (`InteractiveServer`).
245-
246-
`Components/Pages/Counter2.razor`:
247-
248-
```razor
249-
@page "/counter-2"
250-
@rendermode InteractiveServer
251-
252-
<PageTitle>Counter 2</PageTitle>
253-
254-
<h1>Counter 2</h1>
255-
256-
<p role="status">Current count: @currentCount</p>
257-
258-
<button class="btn btn-primary" @onclick="IncrementCount">Click me</button>
259-
260-
@code {
261-
private int currentCount = 0;
262-
263-
private void IncrementCount()
264-
{
265-
currentCount++;
266-
}
267-
}
268-
```
269-
270-
1. Set a breakpoint on the `currentCount++;` line in the `Counter2` component.
218+
1. In the server app, open the statically-rendered `Weather` component (`Components/Pages/Weather.razor`) and set a breakpoint anywhere in the `OnInitializedAsync` method.
271219
1. Select the **Start Debugging** button in the UI or press <kbd>F5</kbd> (**Start Debugging**) to run the app in the debugger.
272-
1. In the browser, navigate to the `Counter2` page at `/counter-2`. Wait a few seconds for the debug proxy to load and run. Select the **Click me** button to hit the breakpoint.
220+
1. In the browser, navigate to the `Weather` page at `/weather`. Wait a few seconds for the debug proxy to load and run. Application execution stops at the breakpoint.
273221
1. Select the **Continue** button in the UI or press <kbd>F5</kbd> (**Continue**) to continue execution.
274222

275223
Breakpoints are **not** hit during app startup before the debug proxy is running. This includes breakpoints in the `Program` file and breakpoints in the [`OnInitialized{Async}` lifecycle methods](xref:blazor/components/lifecycle#component-initialization-oninitializedasync) of components that are loaded by the first page requested from the app.
@@ -437,8 +385,8 @@ The additional options in the following table only apply to **hosted Blazor WebA
437385

438386
*The guidance in this section applies debugging Blazor WebAssembly apps in:*
439387

440-
* *Google Chrome running on Windows or macOS.*
441-
* *Microsoft Edge running on Windows.*
388+
* ***Google Chrome*** *running on Windows or macOS.*
389+
* ***Microsoft Edge** *running on Windows.*
442390

443391
1. Run the app in a command shell with `dotnet watch` (or `dotnet run`).
444392
1. Launch a browser and navigate to the app's URL.

0 commit comments

Comments
 (0)