BlazorGatewayExtensions
Class static net8.0
Extension methods for adding Blazor WebAssembly apps and gateway resources.
namespace Aspire.Hosting;
public static class BlazorGatewayExtensions{ // ...}Methods4
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.
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.