BlazorGatewayExtensions
Classstaticnet10.0
Extension methods for adding Blazor WebAssembly apps and gateway resources.
namespace Aspire.Hosting;
public static class BlazorGatewayExtensions{ // ...}6 members
Methods6
Section titled MethodsAddBlazorGateway(IDistributedApplicationBuilder, string)extensionats exportIResourceBuilder<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. AddBlazorWasmApp(IDistributedApplicationBuilder, string, string)extensionats exportIResourceBuilder<BlazorWasmAppResource> Registers a Blazor WebAssembly project as a resource without launching it as a process. Prefer AddBlazorWasmProject<TProject> which uses IProjectMetadata for path discovery.
AddBlazorWasmProject(IDistributedApplicationBuilder, string)extensionats ignoredIResourceBuilder<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 ignoredIResourceBuilder<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 ignoredIResourceBuilder<DotnetProjectResource> Attaches a Blazor WebAssembly app to a
Dotnet.DotnetProjectResource -backed Gateway created via BlazorGatewayExtensions.AddDotnetProjectBlazorGateway. Behaves identically to BlazorGatewayExtensions.WithBlazorClientApp.