Blazor
Blazor builds web UI from C# Razor components that run on the server, on WebAssembly in the browser, or both in one Blazor Web App. Interviewers probe render modes and where state lives.
on this pageshowhide
explore
- Render Mode Choice6 questions
- Component Parameters6 questions
- Lifecycle & Rendering5 questions
- EditForm & Input Components6 questions
- IJSRuntime & JS Modules6 questions
- Circuits & Persistent State6 questions
- Page Routes & Navigation6 questions
- AuthorizeView & Auth State5 questions
questions
page 2 of 2In a Blazor Web App with WebAssembly interactivity, what do AddAuthenticationStateSerialization and AddAuthenticationStateDeserialization do, and what are their limits?
basics
~20 sAddAuthenticationStateSerialization persists the server's authentication state into the prerendered page; AddAuthenticationStateDeserialization registers a client AuthenticationStateProvider that reads it back. The copy holds name and role claims by default, never changes until a full reload, and authenticates nothing.
In a Blazor Web App, how does [CascadingParameter] find a CascadingValue, and when would you use IsFixed or AddCascadingValue instead of the component?
basics
~20 sA [CascadingParameter] property receives the value from the closest ancestor CascadingValue of a matching type, or with a matching Name. IsFixed="true" skips change tracking for values that never change; AddCascadingValue registers a root-level value through DI that also reaches interactive components across render mode boundaries.
In a Blazor component list, what do @key and @ref do, and what goes wrong with duplicate keys or a @ref read before rendering?
basics
~20 s@key makes Blazor match list items by a value instead of by position, so each row keeps its own element or component instance; duplicate keys among siblings throw. @ref stores a reference to an element or component instance, which is null until the component has rendered.
In a Blazor Web App, what does EditForm's Enhance parameter change for a statically rendered form, and how does an interactive form submit instead?
basics
~20 sEnhance adds data-enhance, so a static SSR form posts through fetch and Blazor patches the response into the page instead of reloading it. An interactive form sends no HTTP POST at all: submit is an event handled in .NET.
A statically rendered Blazor Web App page posts a volunteer sign-up EditForm and gets a 400 or loses the typed values; how do FormName and [SupplyParameterFromForm] fix it?
basics
~20 sUnder static SSR each submit is a new HTTP POST to the page. FormName tells Blazor which form's handler to run, and [SupplyParameterFromForm] maps the posted fields onto the model property; without them the post is rejected or the values are lost.
In a Blazor Web App, how do you load a collocated JavaScript module as an IJSObjectReference, and dispose it safely when the trail map component is removed?
basics
~10 sCall JS.InvokeAsync<IJSObjectReference>("import", "./Components/Trails/TrailMap.razor.js") after first render and invoke the module's exports. Implement IAsyncDisposable: tell the module to tear down the map, then DisposeAsync the reference, catching JSDisconnectedException when the circuit is gone.
In a Blazor weather widget that polls on a timer and holds a JavaScript chart, how should IAsyncDisposable be implemented, and when does Blazor call it?
basics
~20 sAdd @implements IAsyncDisposable and, in DisposeAsync, cancel pending work, stop the timer, unsubscribe from service events and release JavaScript objects. Blazor calls it when the component leaves the UI or, on the server, when its circuit is torn down; with both interfaces only DisposeAsync runs.
In Blazor, how do StateHasChanged, ShouldRender and the render tree diff decide what a component sends to the DOM, and when is overriding ShouldRender worth it?
basics
~20 sStateHasChanged queues one render unless one is already pending; ShouldRender can veto it except on the first render. A render rebuilds the component's render tree and diffs it against the previous one, so only changed elements, attributes and text are sent as DOM edits.
In a Blazor Web App, why does a static page that passes ChildContent to a child with @rendermode InteractiveServer throw, and what other render-mode boundary rules apply?
basics
~20 sA render mode on a child starts a new boundary whose parameters are serialized into the page for the interactive runtime. A RenderFragment is a delegate, arbitrary code, so it cannot be serialized and Blazor throws an InvalidOperationException.
In ASP.NET Core 10 Blazor, how do Router's NotFoundPage and NavigationManager.NotFound() handle a plant id that does not exist, across render modes?
basics
~20 sRouter.NotFoundPage names a routable component shown when nothing matches; a page calls NavigationManager.NotFound() when its data is missing. Under static SSR and prerendering that sets a 404 and renders the page; interactively only global routers show it.
On Blazor Interactive Server, what happens to a user's circuit and cake basket when the connection drops, and what do CircuitOptions and .NET 10 circuit persistence change?
basics
~20 sThe server keeps a disconnected circuit, by default up to 100 for 3 minutes, while the reconnect UI retries; reconnecting in time loses nothing. In .NET 10, an evicted or paused circuit's [PersistentState] values can resume into a new circuit unless the page reloads.
In ASP.NET Core 10 Blazor, how does [PersistentState] stop a prerendered component from loading its data twice, and what code did it replace?
basics
~20 sA prerendered component initializes twice: once on the server for HTML, then again when it becomes interactive. [PersistentState] on a public property serializes its prerendered value into the page and restores it before the interactive OnInitializedAsync, so Cakes ??= await Load() skips the second load.
For an employee self-service portal built as a .NET 10 Blazor Web App, mostly static pages plus a few interactive widgets, how would you choose render modes?
basics
~20 sDefault to static SSR for read-mostly pages and put an interactive mode only on the widgets that need it, choosing Server, WebAssembly or Auto from latency, concurrent users, offline needs and data access. Revisit if most pages become interactive or the portal must work offline.
In a Blazor Web App, what is a JavaScript initializer module, and which of its exported functions run before and after Blazor starts?
basics
~20 sA JS initializer is a module named {ASSEMBLY NAME}.lib.module.js in wwwroot that Blazor imports at startup. In a Blazor Web App it may export beforeWebStart and afterWebStarted, plus per-runtime hooks such as beforeServerStart or afterWebAssemblyStarted.
In Blazor WebAssembly, what do the [JSImport] and [JSExport] attributes offer over IJSRuntime, and why can they not run in an Interactive Server component?
basics
~20 s[JSImport] and [JSExport] are the .NET WebAssembly runtime's own interop: source-generated, in-process, often synchronous calls with typed marshalling instead of JSON. They exist only in the browser runtime, so server-run code, including Interactive Server components, cannot use them.
showing 31–46 of 46