SPA Layout
Program.cs
- Main
- Call CreateHostBuilder
- CreateHostBuilder
- Call Startup class
Startup.cs
- Startup
- Call
_Host.cshtml
- Call
_Host.cshtml
- Call
App.razor
App.razor
- define layout in
DefaultLayout
- Call
MainLayout.razor
- Router Componenet
- AppAssembly: Gets or sets the assembly that should be searched for components matching the URI.
- Found: Gets or sets the content to display when a match is found for the requested route.
- NotFound: Gets or sets the content to display when no match is found for the requested route.
MainLayout.razor
- Call
NavMenu.razor
- Call
Body
- Body Property
- Gets the content to be rendered inside the layout.
NavMenu.razor
- Redirect Web
- For mobile, side Menu can be a toggle
Rout
URI
- Pages\ _Host.cshtml
- define how to rout
Navigation
- NavigationManager
- You can use not only
<a>
Tag, but alsoNavigationManager
- Navigates to the specified URI
- You can use not only
- Pages\Counter.razor
- Use
Defendency Injection
- Use
URI Utilizing
-
@page
- You can use URI components value
Page Layout
MainLayout.razor
- Base Layout in Blazor
- LayoutComponentBase
- Optional base class for components that represent a layout.
- Alternatively, components may implement Microsoft.AspNetCore.Components.IComponent directly and declare their own parameter named Microsoft.AspNetCore.Components.LayoutComponentBase.Body.
Layout Customizing
- Shared
- Create new layout by razor component
- link this layout in razor component of
Pages
by@layout
- Shared\MainLayout2.razor
- Pages\Counter.razor
- Pages
- link this layout in
[folder]\_imports.razor
by@layout
- It changes all layout of the folder
- Pages_imports.razor
- link this layout in