BlazorGatewayExtensions
Classstaticnet10.0
Extension methods for adding Blazor WebAssembly apps and gateway resources.
namespace Aspire.Hosting;
public static class BlazorGatewayExtensions{ // ...}7 members
Methods7
Section titled MethodsIResourceBuilder<ProjectResource> Registers the built-in Blazor Gateway as a file-based C# app. The gateway is shipped as Gateway.cs alongside this library and launched via
AddCSharpApp . No separate project is needed. IResourceBuilder<BlazorWasmAppResource> Registers a Blazor WebAssembly project as a resource without launching it as a process. Prefer AddBlazorWasmProject<TProject> which uses IProjectMetadata for path discovery.
IResourceBuilder<BlazorWasmAppResource> Registers a Blazor WebAssembly project as a resource using the Aspire-generated IProjectMetadata type to discover the project path. The resource name becomes the URL path prefix (e.g., "store" → served at /store/). Use WithReference() to declare service dependencies.
AddDotnetProjectBlazorGateway(IDistributedApplicationBuilder, string) extensionexperimentalats exportIResourceBuilder<DotnetProjectResource> Registers the built-in Blazor Gateway backed by an experimental
Dotnet.DotnetProjectResource from Aspire.Hosting.Dotnet (the run/watch-capable .NET resource), rather than the ApplicationModel.ProjectResource used by BlazorGatewayExtensions.AddBlazorGateway . The gateway is shipped as Gateway.cs alongside this library and launched via AddDotnetProject . No separate project is needed. WithBlazorClientApp(IResourceBuilder<ProjectResource>, IResourceBuilder<BlazorWasmAppResource>, string, string, bool) extensionats exportIResourceBuilder<ProjectResource> Attaches a Blazor WebAssembly app to the Gateway. The resource name is used as the URL path prefix (e.g., resource "store" → /store/). Service names are derived from WithReference() annotations on the WASM resource. Service references from the WASM app are automatically forwarded to the gateway so the gateway can resolve service endpoints for YARP proxying.
WithBlazorClientApp(IResourceBuilder<DotnetProjectResource>, IResourceBuilder<BlazorWasmAppResource>, string, string, bool) extensionexperimentalats exportIResourceBuilder<DotnetProjectResource> Attaches a Blazor WebAssembly app to a
Dotnet.DotnetProjectResource -backed Gateway created via BlazorGatewayExtensions.AddDotnetProjectBlazorGateway . Behaves identically to BlazorGatewayExtensions.WithBlazorClientApp . IResourceBuilder<BlazorWasmAppResource> Configures the browser launched when starting a debug session for the Blazor WebAssembly app. The value is read when the debugger is registered on the gateway, so call this before
BlazorGatewayExtensions.WithBlazorClientApp or BlazorGatewayExtensions.WithBlazorClientApp attaches the app.