How does the Blazor Router component decide which component to render?

Last updated 5 July 2026

The Router component scans the assemblies you specify for components decorated with @page directives, builds a route table, and matches the current URL against it to pick the component to render.

  • Route table construction: AppAssembly (and AdditionalAssemblies) are reflected for RouteAttribute entries generated from @page.

  • Matching the URL:

    • On navigation the router matches the path, applies route constraints, and renders inside <Found> via RouteView.

    • Literal routes are preferred over parameterized ones when both match.

  • No match: The <NotFound> template renders instead.

  • Layout application: RouteView wraps the matched component in its DefaultLayout (unless the page specifies its own).

[lang:razor] <Router AppAssembly="@typeof(Program).Assembly"> <Found Context="routeData"> <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" /> </Found> <NotFound> <p>Sorry, nothing here.</p> </NotFound> </Router>

  • https://learn.microsoft.com/en-us/aspnet/core/blazor/fundamentals/routing?view=aspnetcore-10.0
  • https://learn.microsoft.com/en-us/dotnet/architecture/blazor-for-web-forms-developers/pages-routing-layouts
  • https://www.telerik.com/blogs/blazor-basics-blazor-routing-navigation-fundamentals
  • https://www.jetbrains.com/guide/dotnet/tutorials/blazor-essentials/routing/
  • https://www.adaface.com/blog/blazor-interview-questions/
  • https://blazor-university.com/routing/defining-routes/
  • https://chrissainty.com/an-in-depth-look-at-routing-in-blazor/
All Blazor interview questions