BlazorHostedExtensions Methods
Class Methods 2 members
Extension methods for configuring a Blazor Web App (hosted model) to proxy service calls and telemetry from its WebAssembly client.
ProxyBlazorService(IResourceBuilder<ProjectResource>, IResourceBuilder<IResourceWithServiceDiscovery>, string) Section titled ProxyBlazorService(IResourceBuilder<ProjectResource>, IResourceBuilder<IResourceWithServiceDiscovery>, string) extension IResourceBuilder<ProjectResource> Configures the host to proxy requests from the WebAssembly client to the specified service. The WASM client can reach this service via
/{apiPrefix}/{serviceName}/{path}. YARP routes and clusters are emitted as environment variables. A /_blazor/_configuration response is built so the WASM client gets the proxy URL. This is an explicit opt-in — WithReference makes the service available to the server, while ProxyBlazorService additionally makes it available to the WASM client. public static class BlazorHostedExtensions{ public static IResourceBuilder<ProjectResource> ProxyBlazorService( this IResourceBuilder<ProjectResource> host, IResourceBuilder<IResourceWithServiceDiscovery> service, string apiPrefix = "_api") { // ... }}Parameters
host IResourceBuilder<ProjectResource> The host resource builder. service IResourceBuilder<IResourceWithServiceDiscovery> The service to proxy. apiPrefix string optional The URL path prefix for API proxy routes. Defaults to "_api". ProxyBlazorTelemetry(IResourceBuilder<ProjectResource>, string) Section titled ProxyBlazorTelemetry(IResourceBuilder<ProjectResource>, string) extension IResourceBuilder<ProjectResource> Configures the host to proxy OpenTelemetry data from the WebAssembly client to the Aspire dashboard. The WASM client sends OTLP data to
/{otlpPrefix}/{path} which gets forwarded to the dashboard. Also sets the OTEL_SERVICE_NAME in the client configuration so telemetry from the WASM client appears with the correct service name in the dashboard. public static class BlazorHostedExtensions{ public static IResourceBuilder<ProjectResource> ProxyBlazorTelemetry( this IResourceBuilder<ProjectResource> host, string otlpPrefix = "_otlp") { // ... }}Parameters
host IResourceBuilder<ProjectResource> The host resource builder. otlpPrefix string optional The URL path prefix for OTLP proxy routes. Defaults to "_otlp".