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
.Clientproject- 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
.Clientproject
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 includesNavLinkcomponentsNavMenu.razor.css— the stylesheet for the app’s navigation menu
Pages/— contains app’s routable server-side components; route for each page specified with@pagedirective
Properties/launchSettings.json— development environment configuration
wwwroot/— the web root folder; holds app’s public static assets_Imports.razor— common Razor directivesappsettings.jsonorappsettings.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 usingRoutercomponentProgram.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 includesNavLinkcomponentsNavMenu.razor.css— the stylesheet for the app’s navigation menu
Pages/— contains routable client-side components; route for each page specified with@pagedirectivewwwroot/— the web root folder; holds app’s public static assetsappsettings.jsonorappsettings.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 usingRoutercomponent
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 includesNavLinkcomponentsNavMenu.razor.css— the stylesheet for the app’s navigation menu
Pages/— contains app’s routable components; route for each page specified with@pagedirectiveCounter.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.jsonorappsettings.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
divDOM element withidofappspecifies where the rootAppcomponent 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 theRoutercomponentProgram.cs- Entry point; sets up WASM host
- The root component collection
builder.RootComponents.Add<App>("#app")specifies thatAppis the root component and that it can be found in thedivDOM collection withidofappinwwwroot/index.html