BlazorGatewayExtensions Methods
Class Methods 4 members
Extension methods for adding Blazor WebAssembly apps and gateway resources.
AddBlazorGateway(IDistributedApplicationBuilder, string) Section titled AddBlazorGateway(IDistributedApplicationBuilder, string) extension IResourceBuilder<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
builder IDistributedApplicationBuilder name string AddBlazorWasmApp(IDistributedApplicationBuilder, string, string) Section titled AddBlazorWasmApp(IDistributedApplicationBuilder, string, string) extension 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.
public static class BlazorGatewayExtensions{ public static IResourceBuilder<BlazorWasmAppResource> AddBlazorWasmApp( this IDistributedApplicationBuilder builder, string name, string projectPath) { // ... }}Parameters
builder IDistributedApplicationBuilder name string projectPath string AddBlazorWasmProject(IDistributedApplicationBuilder, string) Section titled AddBlazorWasmProject(IDistributedApplicationBuilder, string) extension 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.
public static class BlazorGatewayExtensions{ public static IResourceBuilder<BlazorWasmAppResource> AddBlazorWasmProject<TProject>( this IDistributedApplicationBuilder builder, string name) { // ... }}Parameters
builder IDistributedApplicationBuilder name string WithBlazorClientApp(IResourceBuilder<ProjectResource>, IResourceBuilder<BlazorWasmAppResource>, string, string, bool) Section titled WithBlazorClientApp(IResourceBuilder<ProjectResource>, IResourceBuilder<BlazorWasmAppResource>, string, string, bool) extension IResourceBuilder<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
gateway IResourceBuilder<ProjectResource> The gateway resource builder. wasmApp IResourceBuilder<BlazorWasmAppResource> The Blazor WebAssembly app to attach to the gateway. apiPrefix string optional The URL path prefix for API proxy routes. Defaults to "_api". otlpPrefix string optional The URL path prefix for OTLP proxy routes. Defaults to "_otlp". proxyTelemetry bool optional true to expose the OTLP proxy for the client app; otherwise, false.