RouteView

If a user requests a route that exists, RouteView will be the first component to respond to the request. RouteView will decide the default layout, then take the route data from the preview component and pass it to the next component in the chain.

You can download the example code used in this topic on GitHub.

Change the default layout

Changing the default layout in RouteView means changing the default layout for the whole website.

  1. Create a layout as described in Theming and Layouts.
  2. Assuming you have SecondaryLayout as your default layout, open App.razor, look for the existing <RouteView> component and change it to:
<RouteView RouteData="routeData" DefaultLayout="typeof(SecondaryLayout)" />
BLAZOR SCHOOL
Designed and built with care by our dedicated team, with contributions from a supportive community. We strive to provide the best learning experience for our users.
Docs licensed CC-BY-SA-4.0
Copyright © 2021-2025 Blazor School
An unhandled error has occurred. Reload 🗙