Blazor Web App (template = blazor
) project structure
Used for both server-side rendered (SSR) and client-side rendered (CSR) apps.
- If both interactive SSR and CSR are selected on app creation, the template uses the Interactive Auto render mode
- If Interactive WebAssembly is selected, the solution also includes an additional
.Client
project- The built output in this project is downloaded to and executed on the client
- Components using Interactive WebAssembly or Interactive Auto must be located in the
.Client
project
For server-only projects:
/
Components/
— holds shared componentsLayout/
MainLayout.razor
— the app’s layout componentMainLayout.razor.css
— the stylesheet for the app’s main layout
NavMenu.razor
— implements sidebar navigation and includesNavLink
componentsNavMenu.razor.css
— the stylesheet for the app’s navigation menu
Pages/
— contains app’s routable server-side components; route for each page specified with@page
directive
Properties/
launchSettings.json
— development environment configuration
wwwroot/
— the web root folder; holds app’s public static assets_Imports.razor
— common Razor directivesappsettings.json
orappsettings.Development.json
— holds configuration settingsApp.razor
- The app’s root component; the first component loaded
- Contains
<head>
and<body>
content and the Blazor<script>
tag
Routes.razor
— sets up routing usingRouter
componentProgram.cs
— entry point; sets up ASP.NET Core web app host; contains startup logic, service registrations, configuration, logging, and request processing pipelineAddRazorComponents()
— adds services for Razor componentsAddInteractiveServerComponents()
— adds services for rendering Interactive Server componentsAddInteractiveWebAssemblyComponents()
— adds services for rendering Interactive WebAssembly componentsMapRazorComponents()
— discovers available components and specifies root component of appAddInteractiveServerRenderMode()
- configures interactive SSR modeAddInteractiveWebAssemblyRenderMode()
— configures interactive WebAssembly render mode
If a client project exists:
/.Client/
Layout/
MainLayout.razor
— the app’s layout componentMainLayout.razor.css
— the stylesheet for the app’s main layout
NavMenu.razor
— implements sidebar navigation and includesNavLink
componentsNavMenu.razor.css
— the stylesheet for the app’s navigation menu
Pages/
— contains routable client-side components; route for each page specified with@page
directivewwwroot/
— the web root folder; holds app’s public static assetsappsettings.json
orappsettings.Development.json
— holds configuration settings
_Imports.razor
— common Razor directivesProgram.cs
— entry point; sets up WASM host; contains startup logic, service registrations, configuration, logging, and request processing pipelineRoutes.razor
— sets up routing usingRouter
component
Standalone Blazor WebAssembly (template = blazorwasm
) project structure
/
Layout/
MainLayout.razor
— the app’s layout componentMainLayout.razor.css
— the stylesheet for the app’s main layout
NavMenu.razor
— implements sidebar navigation and includesNavLink
componentsNavMenu.razor.css
— the stylesheet for the app’s navigation menu
Pages/
— contains app’s routable components; route for each page specified with@page
directiveCounter.razor
— implements the demo Counter pageIndex.razor
— implements the demo Home pageWeather.razor
— implements the demo Weather page
wwwroot/
— the web root folder; holds app’s public static assetssample-data/
weather.json
— sample weather data
appsettings.json
orappsettings.Development.json
— holds configuration settingsindex.html
— the root page of the app implemented as an HTML page:- When any page is initially requested, this page is rendered and returned in the response
- The page’s
div
DOM element withid
ofapp
specifies where the rootApp
component is rendered - Contains the Blazor
<script>
tag - Contains
<head>
and<body>
content
Properties/
launchSettings.json
— development environment configuration
_Imports.razor
— common Razor directivesApp.razor
— the app’s root component; the first component loaded; sets up client-side routing using theRouter
componentProgram.cs
- Entry point; sets up WASM host
- The root component collection
builder.RootComponents.Add<App>("#app")
specifies thatApp
is the root component and that it can be found in thediv
DOM collection withid
ofapp
inwwwroot/index.html