Posts

Blazor Server can feel almost magical.

Image
  You write a Razor component: Razor CSHTML <button @onclick="IncrementCount"> Count: @count </button> @code { private int count; private void IncrementCount() { count++; } } The user clicks the button. C# runs on the server. The browser updates. No APIs, no controllers, no custom JavaScript handlers, no explicit fetch calls. It just works. Under the hood, though, there's a specific piece of architecture holding this together: the Blazor circuit . If you're building server-side Blazor apps without a firm grasp on how circuits function, you're flying blind on state management, memory overhead, connection drops, and scaling strategy. Here is what is actually happening under the hood—and how to design around it. What Is a Blazor Circuit? At its core, a circuit is the server-side memory state allocated for a single interactive user session. While your HTML is rendered in the user's browser, the component instances, even...

HTML Invoker Commands in Blazor

Image
  Stop Using JS for Things the Browser Already Handles Blazor makes handling UI events in C# almost effortless. Because of that, it’s tempting to default to @onclick , component state flags, conditional rendering, and JS Interop for every basic interaction. But modern HTML has caught up. The browser now handles many of the small UI toggles we used to build manually. One of the most useful recent additions to web standards is HTML Invoker Commands . Invoker Commands allow an HTML element (usually a button) to declaratively tell another element to perform an action. For example, opening a modal: HTML < button commandfor = "detailsDialog" command = "show-modal" > View Details </ button > Notice what’s missing here: No JavaScript event listeners No Blazor @onclick handlers No bool _isOpen flags tracking visibility No JS Interop calls The browser manages the interaction directly. For Blazor developers, this brings up an important architectural ques...