BlazorGatewayExtensions Methods
ClassMethods4 members
Extension methods for adding Blazor WebAssembly apps and gateway resources.
AddBlazorGateway(IDistributedApplicationBuilder, string)Section titled AddBlazorGateway(IDistributedApplicationBuilder, string)extensionIResourceBuilder<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. public static class BlazorGatewayExtensions{ public static IResourceBuilder<ProjectResource> AddBlazorGateway( this IDistributedApplicationBuilder builder, string name) { // ... }}Parameters
builderIDistributedApplicationBuildernamestringAddBlazorWasmApp(IDistributedApplicationBuilder, string, string)Section titled AddBlazorWasmApp(IDistributedApplicationBuilder, string, string)extensionIResourceBuilder<BlazorWasmAppResource> Registers a Blazor WebAssembly project as a resource without launching it as a process. Prefer AddBlazorWasmProject<TProject> which uses IProjectMetadata for path discovery.
public static class BlazorGatewayExtensions{ public static IResourceBuilder<BlazorWasmAppResource> AddBlazorWasmApp( this IDistributedApplicationBuilder builder, string name, string projectPath) { // ... }}Parameters
builderIDistributedApplicationBuildernamestringprojectPathstringAddBlazorWasmProject(IDistributedApplicationBuilder, string)Section titled AddBlazorWasmProject(IDistributedApplicationBuilder, string)extensionIResourceBuilder<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.
public static class BlazorGatewayExtensions{ public static IResourceBuilder<BlazorWasmAppResource> AddBlazorWasmProject<TProject>( this IDistributedApplicationBuilder builder, string name) { // ... }}Parameters
builderIDistributedApplicationBuildernamestringWithBlazorClientApp(IResourceBuilder<ProjectResource>, IResourceBuilder<BlazorWasmAppResource>, string, string, bool)Section titled WithBlazorClientApp(IResourceBuilder<ProjectResource>, IResourceBuilder<BlazorWasmAppResource>, string, string, bool)extensionIResourceBuilder<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.
public static class BlazorGatewayExtensions{ public static IResourceBuilder<ProjectResource> WithBlazorClientApp( this IResourceBuilder<ProjectResource> gateway, IResourceBuilder<BlazorWasmAppResource> wasmApp, string apiPrefix = "_api", string otlpPrefix = "_otlp", bool proxyTelemetry = true) { // ... }}Parameters
gatewayIResourceBuilder<ProjectResource>The gateway resource builder.wasmAppIResourceBuilder<BlazorWasmAppResource>The Blazor WebAssembly app to attach to the gateway.apiPrefixstringoptionalThe URL path prefix for API proxy routes. Defaults to "_api".otlpPrefixstringoptionalThe URL path prefix for OTLP proxy routes. Defaults to "_otlp".proxyTelemetrybooloptionaltrue to expose the OTLP proxy for the client app; otherwise, false.