diff --git a/aspnetcore/blazor/fundamentals/configuration.md b/aspnetcore/blazor/fundamentals/configuration.md index e47596e7e14b..8b7f15ba03db 100644 --- a/aspnetcore/blazor/fundamentals/configuration.md +++ b/aspnetcore/blazor/fundamentals/configuration.md @@ -42,8 +42,6 @@ Configuration in app settings files are loaded by default. In the following exam `wwwroot/appsettings.json`: - - :::moniker range=">= aspnetcore-7.0" :::code language="json" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/wwwroot/appsettings.json" highlight="2"::: @@ -72,8 +70,6 @@ Inject an instance into `ConfigExample.razor`: - - :::moniker range=">= aspnetcore-7.0" :::code language="razor" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/Pages/configuration/ConfigExample.razor"::: @@ -147,8 +143,6 @@ using Microsoft.Extensions.Configuration.Memory; In the `Program` file: - - :::moniker range=">= aspnetcore-7.0" :::code language="csharp" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/Program.cs" id="snippet1"::: @@ -177,8 +171,6 @@ Inject an instance into `MemoryConfig.razor`: - - :::moniker range=">= aspnetcore-7.0" :::code language="razor" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/Pages/configuration/MemoryConfig.razor"::: diff --git a/aspnetcore/blazor/fundamentals/dependency-injection.md b/aspnetcore/blazor/fundamentals/dependency-injection.md index 341b47912037..eac1dbaa4c48 100644 --- a/aspnetcore/blazor/fundamentals/dependency-injection.md +++ b/aspnetcore/blazor/fundamentals/dependency-injection.md @@ -118,8 +118,6 @@ The `builder` variable represents a (); ``` -:::moniker-end - :::moniker range="< aspnetcore-6.0" After creating a new app, examine the `Startup.ConfigureServices` method in `Startup.cs`: diff --git a/aspnetcore/blazor/fundamentals/handle-errors.md b/aspnetcore/blazor/fundamentals/handle-errors.md index 8f00fabd9c88..a1c7a9ad662e 100644 --- a/aspnetcore/blazor/fundamentals/handle-errors.md +++ b/aspnetcore/blazor/fundamentals/handle-errors.md @@ -503,6 +503,8 @@ In `App.razor`: :::moniker-end +:::moniker range=">= aspnetcore-6.0" + To process errors in a component: * Designate the `Error` component as a [`CascadingParameter`](xref:blazor/components/cascading-values-and-parameters#cascadingparameter-attribute) in the [`@code`](xref:mvc/views/razor#code) block. In an example `Counter` component in an app based on a Blazor project template, add the following `Error` property: @@ -718,8 +720,6 @@ In the following example where - :::moniker range=">= aspnetcore-7.0" :::code language="razor" source="~/../blazor-samples/7.0/BlazorSample_Server/Pages/handle-errors/ProductDetails.razor" highlight="11,27-39"::: diff --git a/aspnetcore/blazor/fundamentals/logging.md b/aspnetcore/blazor/fundamentals/logging.md index 00ce8276e7ed..8edfe7b65e75 100644 --- a/aspnetcore/blazor/fundamentals/logging.md +++ b/aspnetcore/blazor/fundamentals/logging.md @@ -50,7 +50,7 @@ The `using` directive for is required to sup The following example: -* [Injects](xref:blazor/fundamentals/dependency-injection) an (`ILogger`) object to create a logger. The log's *category* is the fully qualified name of the component's type, `Counter`. +* [Injects](xref:blazor/fundamentals/dependency-injection) an (`ILogger`) object to create a logger. The log's *category* is the fully qualified name of the component's type, `Counter`. * Calls to log at the level. `Counter1.razor`: diff --git a/aspnetcore/blazor/fundamentals/routing.md b/aspnetcore/blazor/fundamentals/routing.md index 9abf3ed0d531..49433047babd 100644 --- a/aspnetcore/blazor/fundamentals/routing.md +++ b/aspnetcore/blazor/fundamentals/routing.md @@ -48,8 +48,6 @@ Components support multiple route templates using multiple [`@page` directives]( `BlazorRoute.razor`: - - :::moniker range=">= aspnetcore-7.0" :::code language="razor" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/Pages/routing/BlazorRoute.razor" highlight="1-2"::: @@ -114,6 +112,9 @@ When the component navigat ## Provide custom content when content isn't found + + The component allows the app to specify custom content if content isn't found for the requested route. Set custom content in the component's template: @@ -163,8 +164,6 @@ The router uses route parameters to populate the corresponding [component parame `RouteParameter1.razor`: - - :::moniker range=">= aspnetcore-7.0" :::code language="razor" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/Pages/routing/RouteParameter1.razor" highlight="1"::: @@ -203,8 +202,6 @@ Optional parameters aren't supported. In the following example, two [`@page` dir `RouteParameter2.razor`: - - :::moniker range=">= aspnetcore-7.0" :::code language="razor" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/Pages/routing/RouteParameter2.razor" highlight="1"::: @@ -256,8 +253,6 @@ In the following example, the route to the `User` component only matches if: `User.razor`: - - :::moniker range=">= aspnetcore-7.0" :::code language="razor" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/Pages/routing/User.razor" highlight="1"::: @@ -430,8 +425,6 @@ Catch-all route parameters are: :::moniker-end - - :::moniker range=">= aspnetcore-7.0" :::code language="razor" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/Pages/routing/CatchAll.razor"::: @@ -550,8 +543,6 @@ The following component: `Navigate.razor`: - - :::moniker range=">= aspnetcore-7.0" :::code language="razor" source="~/../blazor-samples/7.0/BlazorSample_WebAssembly/Pages/routing/Navigate.razor"::: diff --git a/aspnetcore/blazor/fundamentals/signalr.md b/aspnetcore/blazor/fundamentals/signalr.md index be2833ef8910..838fa4ccab88 100644 --- a/aspnetcore/blazor/fundamentals/signalr.md +++ b/aspnetcore/blazor/fundamentals/signalr.md @@ -29,31 +29,14 @@ For general guidance on ASP.NET Core SignalR configuration, see the topics in th ## Disable response compression for Hot Reload -When using [Hot Reload](xref:test/hot-reload), disable Response Compression Middleware in the `Development` environment. The following examples use the existing environment check in a project created from a Blazor project template. Whether or not the default code from a project template is used, always call first in the request processing pipeline. +When using [Hot Reload](xref:test/hot-reload), disable Response Compression Middleware in the `Development` environment. Whether or not the default code from a project template is used, always call first in the request processing pipeline. -In the server-side `Program` file: +In the `Program` file: ```csharp if (!app.Environment.IsDevelopment()) { app.UseResponseCompression(); - app.UseExceptionHandler("/Error"); - app.UseHsts(); -} -``` - -In the client-side `Program` file: - -```csharp -if (app.Environment.IsDevelopment()) -{ - app.UseWebAssemblyDebugging(); -} -else -{ - app.UseResponseCompression(); - app.UseExceptionHandler("/Error"); - app.UseHsts(); } ``` diff --git a/aspnetcore/blazor/fundamentals/startup.md b/aspnetcore/blazor/fundamentals/startup.md index 9a10e2ea75fc..44797a121a00 100644 --- a/aspnetcore/blazor/fundamentals/startup.md +++ b/aspnetcore/blazor/fundamentals/startup.md @@ -296,60 +296,64 @@ Control headers at startup in C# code using the following approaches. In the following examples, a [Content Security Policy (CSP)](https://developer.mozilla.org/docs/Web/HTTP/Headers/Content-Security-Policy) is applied to the app via a CSP header. The `{POLICY STRING}` placeholder is the CSP policy string. -* In server-side and prerendered client-side scenarios, use [ASP.NET Core Middleware](xref:fundamentals/middleware/index) to control the headers collection. +### Server-side and prerendered client-side scenarios + +Use [ASP.NET Core Middleware](xref:fundamentals/middleware/index) to control the headers collection. :::moniker range=">= aspnetcore-6.0" - In the `Program` file: +In the `Program` file: :::moniker-end :::moniker range="< aspnetcore-6.0" - In `Startup.Configure` of `Startup.cs`: +In `Startup.Configure` of `Startup.cs`: :::moniker-end - ```csharp - app.Use(async (context, next) => - { - context.Response.Headers.Add("Content-Security-Policy", "{POLICY STRING}"); - await next(); - }); - ``` +```csharp +app.Use(async (context, next) => +{ + context.Response.Headers.Add("Content-Security-Policy", "{POLICY STRING}"); + await next(); +}); +``` - The preceding example uses inline middleware, but you can also create a custom middleware class and call the middleware with an extension method in the `Program` file. For more information, see . +The preceding example uses inline middleware, but you can also create a custom middleware class and call the middleware with an extension method in the `Program` file. For more information, see . -* For client-side development without prerendering, pass to that specifies response headers at the stage. +### Client-side development without prerendering + +Pass to that specifies response headers at the stage. :::moniker range=">= aspnetcore-6.0" - In the server-side `Program` file: +In the server-side `Program` file: :::moniker-end :::moniker range="< aspnetcore-6.0" - In `Startup.Configure` of `Startup.cs`: +In `Startup.Configure` of `Startup.cs`: :::moniker-end - ```csharp - var staticFileOptions = new StaticFileOptions - { - OnPrepareResponse = context => - { - context.Context.Response.Headers.Add("Content-Security-Policy", - "{POLICY STRING}"); - } - }; +```csharp +var staticFileOptions = new StaticFileOptions +{ + OnPrepareResponse = context => + { + context.Context.Response.Headers.Add("Content-Security-Policy", + "{POLICY STRING}"); + } +}; - ... +... - app.MapFallbackToFile("index.html", staticFileOptions); - ``` +app.MapFallbackToFile("index.html", staticFileOptions); +``` For more information on CSPs, see . diff --git a/aspnetcore/blazor/project-structure.md b/aspnetcore/blazor/project-structure.md index d6f819af5851..95bea766e16c 100644 --- a/aspnetcore/blazor/project-structure.md +++ b/aspnetcore/blazor/project-structure.md @@ -18,9 +18,7 @@ This article describes the files and folders that make up a Blazor app generated ## Blazor Web App - - -Blazor Web App project templates: `blazor`, `blazor-empty` +Blazor Web App project template: `blazor` Project structure: diff --git a/aspnetcore/blazor/tooling.md b/aspnetcore/blazor/tooling.md index 5a0072bc7bab..d006a224f2d2 100644 --- a/aspnetcore/blazor/tooling.md +++ b/aspnetcore/blazor/tooling.md @@ -118,13 +118,6 @@ Create a new project: dotnet new blazor -o BlazorApp ``` - - -* Alternatively, create a Blazor Web App without demonstration code and Bootstrap using the `blazor-empty` project template: - - ```dotnetcli - dotnet new blazor-empty -o BlazorApp - To enable interactivity with server-side rendering (SSR), add the `--use-server` option to the command: @@ -614,9 +607,7 @@ The Blazor framework provides templates for creating new apps. The templates are :::moniker range=">= aspnetcore-8.0" - - -* Blazor Web App project template (*recommended*): `blazor`, `blazor-empty` +* Blazor Web App project template (*recommended*): `blazor` * Blazor WebAssembly project templates: `blazorwasm`, `blazorwasm-empty` :::moniker-end diff --git a/aspnetcore/blazor/tutorials/build-a-blazor-app.md b/aspnetcore/blazor/tutorials/build-a-blazor-app.md index f22fffb31f47..52e2039ae652 100644 --- a/aspnetcore/blazor/tutorials/build-a-blazor-app.md +++ b/aspnetcore/blazor/tutorials/build-a-blazor-app.md @@ -93,7 +93,7 @@ The `-n|--name` option in the preceding command specifies the name of the new Ra Open the `Todo` component in any file editor and make the following changes at the top of the file: - + * Add an `@page` Razor directive with a relative URL of `/todo`. * Add the `[RenderModeServer]` attribute. The attribute indicates that for this component the render mode should be server-side rendering (SSR), which means that the `Todo` component is rendered interactively on the server via Blazor Server hosting with server-side prerendering. diff --git a/aspnetcore/blazor/tutorials/index.md b/aspnetcore/blazor/tutorials/index.md index 337d22c3c75a..3d4f2a98e91d 100644 --- a/aspnetcore/blazor/tutorials/index.md +++ b/aspnetcore/blazor/tutorials/index.md @@ -22,7 +22,7 @@ For an overview of Blazor, see . * - + *