---
title: ASP.NET Core Blazor routing
author: guardrex
description: Learn how to route requests in apps and about the NavLink component.
monikerRange: '>= aspnetcore-3.0'
ms.author: riande
ms.custom: mvc
ms.date: 08/23/2019
uid: blazor/routing
---
# ASP.NET Core Blazor routing
By [Luke Latham](https://github.com/guardrex)
Learn how to route requests and how to use the `NavLink` component to create navigation links in Blazor apps.
## ASP.NET Core endpoint routing integration
Blazor server-side 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 `MapBlazorHub` in `Startup.Configure`:
[!code-csharp[](routing/samples_snapshot/3.x/Startup.cs?highlight=5)]
## Route templates
The `Router` component enables routing, and a route template is provided to each accessible component. The `Router` component appears in the *App.razor* file:
In a Blazor server-side or client-side app:
```cshtml
Sorry, there's nothing at this address.
```
When a *.razor* file with an `@page` directive is compiled, the generated class is provided a specifying the route template. At runtime, the router looks for component classes with a `RouteAttribute` and renders the component with a route template that matches the requested URL.
Multiple route templates can be applied to a component. The following component responds to requests for `/BlazorRoute` and `/DifferentBlazorRoute`:
[!code-cshtml[](common/samples/3.x/BlazorSample/Pages/BlazorRoute.razor?name=snippet_BlazorRoute)]
> [!IMPORTANT]
> For URLs to resolve correctly, the app must include a `` tag in its *wwwroot/index.html* file (Blazor client-side) or *Pages/_Host.cshtml* file (Blazor server-side) with the app base path specified in the `href` attribute (``). For more information, see .
## Provide custom content when content isn't found
The `Router` component allows the app to specify custom content if content isn't found for the requested route.
In the *App.razor* file, set custom content in the `` template parameter of the `Router` component:
```cshtml
The browser is forced to load the new page from the server, whether or not the URI is normally handled by the client-side router.
|
| `LocationChanged` | An event that fires when the navigation location has changed. |
| `ToAbsoluteUri` | Converts a relative URI into an absolute URI. |
| `ToBaseRelativePath` | Given a base URI (for example, a URI previously returned by `GetBaseUri`), converts an absolute URI into a URI relative to the base URI prefix. |
The following component navigates to the app's `Counter` component when the button is selected:
```cshtml
@page "/navigate"
@inject NavigationManager NavigationManager