Skip to content

Conversation

@guardrex
Copy link
Collaborator

@guardrex guardrex commented Sep 23, 2025

Fixes #35683
Fixes #36190

Splits roughly along Router component and NavLink/NavigationManager lines.

Not Found spans them, so there's a little bit on the NotFoundPage param in the Routing article with the rest in the Not Found responses section of the new Navigation article.

I'm not planning a review/update of all sections at this time. It would slow me down by a couple of days in reaching the next Blazorfy IT!™ issue, but let me know if you would like to go for a full review on all of this guidance.

I'm inlining code examples because it's taking an awful lot of time ... i.e., 💰💰💰 ... to update sample cross-links every release for no great benefit. The code isn't changing and isn't likely to change for these examples. I'm stripping off the <PageTitle> markup because it came in at 6.0, making the examples apply universally.

Outlines

Routing article

  • Introductory remarks
  • Static versus interactive routing
  • ASP.NET Core endpoint routing integration
  • Route templates
  • Focus an element on navigation
  • Provide custom content when content isn't found
  • Route to components from multiple assemblies
    • Static routing
    • Interactive routing
  • Route parameters
  • Route constraints
  • Avoid file capture in a route parameter
  • Routing with URLs that contain dots
  • Handle asynchronous navigation events with OnNavigateAsync
  • Handle cancellations in OnNavigateAsync
  • User interaction with <Navigating> content

Navigation article

  • Introductory remarks
  • NavLink component
  • URI and navigation state helpers
  • Location changes
  • Navigation Manager redirect behavior during static server-side rendering (static SSR)
  • Not Found responses
  • Enhanced navigation and form handling
  • Produce a URI relative to the base URI prefix
  • Navigation history state
  • Navigation options
  • Query strings
    • Replace a query parameter value when the parameter exists
    • Append a query parameter and value when the parameter doesn't exist
    • Remove a query parameter when the parameter value is null
    • Add, update, and remove query parameters
    • Support for enumerable values
    • Navigate with an added or modified query string
  • Hashed routing to named elements
  • Handle/prevent location changes
  • Dynamically-generated NavLink components via reflection

Internal previews

Toggle expand/collapse
📄 File 🔗 Preview link
aspnetcore/blazor/call-web-api.md aspnetcore/blazor/call-web-api
aspnetcore/blazor/components/built-in-components.md aspnetcore/blazor/components/built-in-components
aspnetcore/blazor/components/index.md aspnetcore/blazor/components/index
aspnetcore/blazor/components/render-modes.md aspnetcore/blazor/components/render-modes
aspnetcore/blazor/components/rendering.md aspnetcore/blazor/components/rendering
aspnetcore/blazor/forms/index.md aspnetcore/blazor/forms/index
aspnetcore/blazor/fundamentals/dependency-injection.md aspnetcore/blazor/fundamentals/dependency-injection
aspnetcore/blazor/fundamentals/navigation.md aspnetcore/blazor/fundamentals/navigation
aspnetcore/blazor/fundamentals/routing.md aspnetcore/blazor/fundamentals/routing
aspnetcore/blazor/fundamentals/startup.md aspnetcore/blazor/fundamentals/startup
aspnetcore/blazor/fundamentals/static-files.md aspnetcore/blazor/fundamentals/static-files
aspnetcore/blazor/host-and-deploy/app-base-path.md aspnetcore/blazor/host-and-deploy/app-base-path
aspnetcore/blazor/javascript-interoperability/location-of-javascript.md aspnetcore/blazor/javascript-interoperability/location-of-javascript
aspnetcore/blazor/javascript-interoperability/static-server-rendering.md aspnetcore/blazor/javascript-interoperability/static-server-rendering
aspnetcore/blazor/project-structure.md aspnetcore/blazor/project-structure
aspnetcore/blazor/security/index.md aspnetcore/blazor/security/index
aspnetcore/blazor/security/webassembly/index.md aspnetcore/blazor/security/webassembly/index
aspnetcore/blazor/state-management/prerendered-state-persistence.md aspnetcore/blazor/state-management/prerendered-state-persistence
aspnetcore/blazor/state-management/server.md aspnetcore/blazor/state-management/server
aspnetcore/blazor/tutorials/movie-database-app/part-3.md aspnetcore/blazor/tutorials/movie-database-app/part-3
aspnetcore/fundamentals/index.md aspnetcore/fundamentals/index
aspnetcore/fundamentals/routing.md aspnetcore/fundamentals/routing
aspnetcore/migration/60-to-70.md aspnetcore/migration/60-to-70
aspnetcore/release-notes/aspnetcore-6.0.md aspnetcore/release-notes/aspnetcore-6.0
aspnetcore/release-notes/aspnetcore-8.0.md aspnetcore/release-notes/aspnetcore-8.0
aspnetcore/security/authentication/passkeys/blazor.md aspnetcore/security/authentication/passkeys/blazor
aspnetcore/toc.yml aspnetcore/toc

@guardrex guardrex self-assigned this Sep 23, 2025
@guardrex guardrex requested a review from danroth27 September 23, 2025 14:28

> [!IMPORTANT]
> Code examples throughout this article show methods called on `Navigation`, which is an injected <xref:Microsoft.AspNetCore.Components.NavigationManager> in classes and components.
Routing in Blazor is achieved by providing a route template to each accessible component in the app with an [`@page`](xref:mvc/views/razor#page) directive. When a Razor file with an `@page` directive is compiled, the generated class is given a <xref:Microsoft.AspNetCore.Mvc.RouteAttribute> specifying the route template. At runtime, the router searches for component classes with a <xref:Microsoft.AspNetCore.Mvc.RouteAttribute> and renders whichever component has a route template that matches the requested URL.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Routing in Blazor is achieved by providing a route template to each accessible component in the app with an [`@page`](xref:mvc/views/razor#page) directive. When a Razor file with an `@page` directive is compiled, the generated class is given a <xref:Microsoft.AspNetCore.Mvc.RouteAttribute> specifying the route template. At runtime, the router searches for component classes with a <xref:Microsoft.AspNetCore.Mvc.RouteAttribute> and renders whichever component has a route template that matches the requested URL.
Routing in Blazor is achieved by providing a route template to each accessible component in the app with an [`@page`](xref:mvc/views/razor#page) directive. When a Razor file with an `@page` directive is compiled, the generated class is given a <xref:Microsoft.AspNetCore.Components.RouteAttribute> specifying the route template. At runtime, the router searches for component classes with a <xref:Microsoft.AspNetCore.Components.RouteAttribute> and renders whichever component has a route template that matches the requested URL.

## Route templates
## ASP.NET Core endpoint routing integration

*This section applies to Blazor Web Apps and Blazor Server apps operating over a circuit.*
Copy link
Member

@danroth27 danroth27 Dec 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The content for .NET 8+ really only covers endpoint routing integration for Blazor Web Apps. The Blazor Server content is only shown for earlier .NET versions. I think this line needs to be within the version range monikers and adjusted accordingly.


:::moniker range=">= aspnetcore-8.0"

The <xref:Microsoft.AspNetCore.Components.Routing.Router> component enables routing to Razor components and is located in the app's `Routes` component (`Components/Routes.razor`).
A Blazor Web App is integrated into [ASP.NET Core Endpoint Routing](xref:fundamentals/routing). An ASP.NET Core app is configured to accept incoming connections for interactive components with <xref:Microsoft.AspNetCore.Builder.RazorComponentsEndpointRouteBuilderExtensions.MapRazorComponents%2A> in the `Program` file. The default root component (first component loaded) is the `App` component (`App.razor`):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The components don't have to be interactive to respond to requests:

Suggested change
A Blazor Web App is integrated into [ASP.NET Core Endpoint Routing](xref:fundamentals/routing). An ASP.NET Core app is configured to accept incoming connections for interactive components with <xref:Microsoft.AspNetCore.Builder.RazorComponentsEndpointRouteBuilderExtensions.MapRazorComponents%2A> in the `Program` file. The default root component (first component loaded) is the `App` component (`App.razor`):
A Blazor Web App is integrated into [ASP.NET Core Endpoint Routing](xref:fundamentals/routing). An ASP.NET Core app is configured with endpoints for routable components and the root component to render for those endpoints with <xref:Microsoft.AspNetCore.Builder.RazorComponentsEndpointRouteBuilderExtensions.MapRazorComponents%2A> in the `Program` file. The default root component (first component loaded) is the `App` component (`App.razor`):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Missing "preceding example" for NavLinkMatch explanation Consider splitting the Blazor *Routing and Navigation* fundamentals article

3 participants