About This Book
In this book you build one web app, LibraryDesk, a small book catalog, from an empty template to a published site. Each chapter adds a page or a feature to the same project: a counter, reusable components, a favorites list, a feedback form, a JSON API, sign-in, live updates, tests, accessibility checks and diagnostics. Along the way you learn where Blazor code runs (on the web server or inside the browser), how data moves between components, and which checks must stay on the server.
You should already be comfortable with C# classes, collections, generics, lambdas, LINQ queries such as Where, events, asynchronous methods and exceptions, and with basic HTML and CSS. Chapter 12 calls JavaScript from C# and explains each line it uses, so reading simple JavaScript is enough. This is a practical book for web developers, and for instructors teaching developers with those foundations. It is not a first programming course.
Following Along
Work through the chapters in order, in one working folder. Chapter 2 creates that folder: it holds a global.json file and the LibraryDesk solution folder, which contains the LibraryDesk server project and the LibraryDesk.Client project. Every later chapter adds to the same project, and its Prerequisites section says where it starts. Chapter 18 adds a LibraryDesk.Tests folder and Chapter 20 adds LibraryDesk.Pwa and LibraryDesk.Pwa.Tests, all beside the solution folder and included in the solution.
File paths in the book are relative to the solution folder. LibraryDesk/Program.cs is the Program.cs file in the server project, and LibraryDesk.Client/Pages/Run.razor is a page in the client project. A listing headed "Add" is a new file to create with exactly that content. "Update" means change an existing file as the sentence before the listing describes. "Read" marks a file to study rather than type. Each chapter's Full Example section collects the complete final versions of the files the chapter added or changed substantially, so you can compare your own.
Visual Studio is the main workspace. Chapter 2 creates LibraryDesk with the project wizard and sets an http launch profile at http://127.0.0.1:58631. Open LibraryDesk/LibraryDesk.slnx, keep the server project as the startup project, Save All, and press F5 to run with the debugger. Shift+F5 stops that run. Chapter 3 shows exactly how to add files, set breakpoints, inspect variables, step through C# and apply Hot Reload. Later chapters use the same project tree, NuGet tools, Test Explorer and Publish pages. Browser DevTools remains the place to inspect requests, rendered HTML and browser storage.
Command-line alternatives are labeled where they are useful. You can follow the alternative route in another editor or on another operating system while using the same code and file organization.
Download the companion code free at unqbd.com/go/blazor3-code. Folder names such as Samples/Checkpoints refer to that download. A checkpoint is the project at the end of its named chapter. If you skip a chapter or cannot find a mistake, stop the current app, copy the previous chapter's complete checkpoint folder in File Explorer to a new working folder, and open its LibraryDesk/LibraryDesk.slnx. For Chapter 4, for example, start with a copy of Chapter03. Work in the copy so generated build files stay out of your clean download.
Each checkpoint folder has a README with its Visual Studio run steps and optional terminal commands. The download's Samples folder holds:
- Windows and Visual Studio 2026 with .NET 11 support and the ASP.NET and web development workload. Chapter 2 checks the installed IDE and creates the project through its wizard. Visual Studio Community is an option subject to its license; no coding-assistant subscription is needed.
- The released .NET 11 SDK, version 11.0.100 or later. global.json pins the SDK family. Framework packages use 11.0.0 with SDK 11.0.100, or the matching later 11.0 patch. The companion uses 11.0.0. SDK and package versions are different numbers.
- A current browser such as Microsoft Edge or Google Chrome. F12 opens the browser's developer tools, introduced in Chapter 3.
- A PowerShell terminal for the explicitly labeled command-line alternatives and local hosting commands. On macOS or Linux, install PowerShell 7 from learn.microsoft.com/powershell/scripting/install/installing-powershell and start it with pwsh for those commands. Use curl where a Windows alternative says curl.exe.
- Python 3 is used for the local static-file server in Chapters 20 and 23 and the optional activity-copy generator. Install Python 3 from python.org if needed. Open PowerShell and run python --version; it should print Python 3 followed by its version. If Windows opens the Store instead, finish installing Python and reopen PowerShell before continuing. Prepared ActivityStarts let you open the exercises directly in Visual Studio. The PWA chapters explain the local server's role separately from writing, debugging and publishing the app in the IDE.
Some screenshots were captured with a .NET 11 release candidate before the released SDK became available. Their captions identify that status. Follow the released version baseline in the text; a pictured prerelease suffix is not a request to change the companion's SDK pin or package versions.
No paid coding assistant, cloud service, production credential or telemetry account is required.
What the Examples Do
LibraryDesk's catalog is a fixed list of sample books, so every run shows the same titles. Favorites live in the memory of the running app, feedback stays in the app, and live notices disappear when the app stops. The sign-in examples in Chapter 11 use two test accounts, reader and librarian, which exist only while the app runs in Development mode on your own computer. No example sends email, takes a payment, changes an external account or deploys anything.
Check each feature where it runs. Component tests (Chapter 18) check component logic, your browser shows what runs in WebAssembly, and a real phone shows the mobile layout. Each chapter tells you which check to use.
How to Use the Answers
Every chapter ends with five multiple-choice questions and an activity. The answers, each with a short explanation, are in the Answer Key at the end of the book.
Do each activity in a copy so the cumulative project stays clean. For Chapters 2 through 23, copy Samples/ActivityStarts/ChapterNN to a new working folder and open its LibraryDesk/LibraryDesk.slnx in Visual Studio. These prepared starts contain the unsolved change or investigation described in the chapter; they are different from the finished checkpoints. Any Tests project supplied for the exercise is included in its solution. Stop the main app before running an exercise on the same port. Chapter 1's activity is a text exercise. Samples/ActivitySolutions preserves solved copies for Chapters 4, 5, 11 and 13; Samples/Activities explains every answer. The optional Python generator under ActivityInvestigations can recreate a fresh start from its checkpoint and checked changes.