From c05b6c0bb7399663fcc32b3472a87b8fcca7e53d Mon Sep 17 00:00:00 2001 From: Luke Latham <1622880+guardrex@users.noreply.github.com> Date: Thu, 14 Jul 2022 14:49:03 -0500 Subject: [PATCH] Passing scoped IJSRuntime to singletons (#26431) --- aspnetcore/blazor/fundamentals/dependency-injection.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/aspnetcore/blazor/fundamentals/dependency-injection.md b/aspnetcore/blazor/fundamentals/dependency-injection.md index 0c08d59bcc..90c2cd0a29 100644 --- a/aspnetcore/blazor/fundamentals/dependency-injection.md +++ b/aspnetcore/blazor/fundamentals/dependency-injection.md @@ -31,7 +31,7 @@ The services shown in the following table are commonly used in Blazor apps. | Service | Lifetime | Description | | ------- | -------- | ----------- | | | Scoped |

Provides methods for sending HTTP requests and receiving HTTP responses from a resource identified by a URI.

The instance of in a Blazor WebAssembly app is registered by the app in `Program.cs` and uses the browser for handling the HTTP traffic in the background.

Blazor Server apps don't include an configured as a service by default. Provide an to a Blazor Server app.

For more information, see .

An is registered as a scoped service, not singleton. For more information, see the [Service lifetime](#service-lifetime) section.

| -| |

**Blazor WebAssembly**: Singleton

**Blazor Server**: Scoped

The Blazor framework registers in the app's service container.

| Represents an instance of a JavaScript runtime where JavaScript calls are dispatched. For more information, see . | +| |

**Blazor WebAssembly**: Singleton

**Blazor Server**: Scoped

The Blazor framework registers in the app's service container.

|

Represents an instance of a JavaScript runtime where JavaScript calls are dispatched. For more information, see .

When seeking to inject the service into a singleton service in Blazor Server apps, take either of the following approaches:

  • Change the service registration to scoped to match 's registration, which is appropriate if the service deals with user-specific state.
  • Pass the into the singleton service's implementation as an argument of its method calls instead of injecting it into the singleton.
| | |

**Blazor WebAssembly**: Singleton

**Blazor Server**: Scoped

The Blazor framework registers in the app's service container.

| Contains helpers for working with URIs and navigation state. For more information, see [URI and navigation state helpers](xref:blazor/fundamentals/routing#uri-and-navigation-state-helpers). | Additional services registered by the Blazor framework are described in the documentation where they're used to describe Blazor features, such as configuration and logging. @@ -412,7 +412,7 @@ The services shown in the following table are commonly used in Blazor apps. | Service | Lifetime | Description | | ------- | -------- | ----------- | | | Scoped |

Provides methods for sending HTTP requests and receiving HTTP responses from a resource identified by a URI.

The instance of in a Blazor WebAssembly app uses the browser for handling the HTTP traffic in the background.

Blazor Server apps don't include an configured as a service by default. Provide an to a Blazor Server app.

For more information, see .

An is registered as a scoped service, not singleton. For more information, see the [Service lifetime](#service-lifetime) section.

| -| |

**Blazor WebAssembly**: Singleton

**Blazor Server**: Scoped

The Blazor framework registers in the app's service container.

| Represents an instance of a JavaScript runtime where JavaScript calls are dispatched. For more information, see . | +| |

**Blazor WebAssembly**: Singleton

**Blazor Server**: Scoped

The Blazor framework registers in the app's service container.

|

Represents an instance of a JavaScript runtime where JavaScript calls are dispatched. For more information, see .

When seeking to inject the service into a singleton service in Blazor Server apps, take either of the following approaches:

  • Change the service registration to scoped to match 's registration, which is appropriate if the service deals with user-specific state.
  • Pass the into the singleton service's implementation as an argument of its method calls instead of injecting it into the singleton.
| | |

**Blazor WebAssembly**: Singleton

**Blazor Server**: Scoped

The Blazor framework registers in the app's service container.

| Contains helpers for working with URIs and navigation state. For more information, see [URI and navigation state helpers](xref:blazor/fundamentals/routing#uri-and-navigation-state-helpers). | Additional services registered by the Blazor framework are described in the documentation where they're used to describe Blazor features, such as configuration and logging. @@ -810,7 +810,7 @@ The services shown in the following table are commonly used in Blazor apps. | Service | Lifetime | Description | | ------- | -------- | ----------- | | | Scoped |

Provides methods for sending HTTP requests and receiving HTTP responses from a resource identified by a URI.

The instance of in a Blazor WebAssembly app uses the browser for handling the HTTP traffic in the background.

Blazor Server apps don't include an configured as a service by default. Provide an to a Blazor Server app.

For more information, see .

An is registered as a scoped service, not singleton. For more information, see the [Service lifetime](#service-lifetime) section.

| -| |

**Blazor WebAssembly**: Singleton

**Blazor Server**: Scoped

The Blazor framework registers in the app's service container.

| Represents an instance of a JavaScript runtime where JavaScript calls are dispatched. For more information, see . | +| |

**Blazor WebAssembly**: Singleton

**Blazor Server**: Scoped

The Blazor framework registers in the app's service container.

|

Represents an instance of a JavaScript runtime where JavaScript calls are dispatched. For more information, see .

When seeking to inject the service into a singleton service in Blazor Server apps, take either of the following approaches:

  • Change the service registration to scoped to match 's registration, which is appropriate if the service deals with user-specific state.
  • Pass the into the singleton service's implementation as an argument of its method calls instead of injecting it into the singleton.
| | |

**Blazor WebAssembly**: Singleton

**Blazor Server**: Scoped

The Blazor framework registers in the app's service container.

| Contains helpers for working with URIs and navigation state. For more information, see [URI and navigation state helpers](xref:blazor/fundamentals/routing#uri-and-navigation-state-helpers). | Additional services registered by the Blazor framework are described in the documentation where they're used to describe Blazor features, such as configuration and logging.