Examining the Routable Razor Components
Explore the key routable Razor components in a Blazor WebAssembly application, including Index, Counter, and FetchData. Learn routing with @page directives, handling events, asynchronous data loading with HttpClient, and component lifecycle methods to build responsive single-page apps.
We'll cover the following...
We'll cover the following...
The routable Razor components are in the Pages folder. There are three routable Razor components in the Demo project:
- The
Indexcomponent - The
Countercomponent - The
FetchDatacomponent
The Index component
The “Home” page of the Demo project uses the Index component that is defined in the Pages\Index.razor file:
The preceding code includes an @page directive that references the root of the web app and some markup. The markup includes a SurveyPrompt component.
The Counter component
The Counter component is more complex than the ...