Current count: @currentCount
-Sorry, there's nothing at this address.
-Current count: @currentCount
+Add a `Layout` folder to the `Components` folder. - +Add a footer component and stylesheet to the `Layout` folder. - @code { - private int currentCount = 0; +`Components/Layout/Footer.razor`: - private void IncrementCount() - { - currentCount++; - } - } - ``` +```razor + +``` -1. Run the project and navigate to the routable `RoutableCounter` component at `/routable-counter`. +In the preceding markup, set the `{APP TITLE}` placeholder to the title of the app. For example: -For more information on namespaces, see the [Component namespaces](#component-namespaces) section. +```html +© 2023 - Blazor Sample - Privacy +``` + +`Components/Layout/Footer.razor.css`: + +```css +.footer { +position: absolute; +bottom: 0; +width: 100%; +white-space: nowrap; +line-height: 60px; +} +``` -## Use routable components in an MVC app +Add a navigation menu component to the `Layout` folder. + +`Components/Layout/NavMenu.razor`: + +```razor + +``` -*This section pertains to adding components that are directly routable from user requests.* +In the preceding markup, set the `{APP TITLE}` placeholder to the title of the app. For example: -To support routable Razor components in MVC apps: +```html +Blazor Sample +``` -1. Follow the guidance in the [Configuration](#configuration) section. +`Components/Layout/NavMenu.razor.css`: -1. Add an `App` component to the project root with the following content. +```css +a.navbar-brand { + white-space: normal; + text-align: center; + word-break: break-all; +} - `App.razor`: +a { + color: #0077cc; +} - ```razor - @using Microsoft.AspNetCore.Components.Routing +.btn-primary { + color: #fff; + background-color: #1b6ec2; + border-color: #1861ac; +} -Sorry, there's nothing at this address.
-Current count: @currentCount
+* For the `{APP TITLE}` placeholder in the `Current count: @currentCount
-@functions { - [BindProperty(SupportsGet=true)] - public int InitialValue { get; set; } + + +@code { + private int currentCount = 0; + + private void IncrementCount() + { + currentCount++; + } } ``` -For more information, see@Message
+ +@code { + [Parameter] + public string? Message { get; set; } } ``` -For more information, seeThis component demonstrates fetching data from the server.
+ protected override async Task OnInitializedAsync() + { + persistingSubscription = + ApplicationState.RegisterOnPersisting(PersistData); -@if (forecasts == null) -{ -Loading...
-} -else -{ -| Date | -Temp. (C) | -Temp. (F) | -Summary | -
|---|---|---|---|
| @forecast.Date.ToShortDateString() | -@forecast.TemperatureC | -@forecast.TemperatureF | -@forecast.Summary | -
Current count: @currentCount
+ + @code { - private WeatherForecast[] forecasts = Array.Empty