BlazorHostedExtensions
Class static net8.0
Extension methods for configuring a Blazor Web App (hosted model) to proxy service calls and telemetry from its WebAssembly client.
namespace Aspire.Hosting;
public static class BlazorHostedExtensions{ // ...}Methods2
Section titled MethodsProxyBlazorService(IResourceBuilder<ProjectResource>, IResourceBuilder<IResourceWithServiceDiscovery>, string)extensionats ignoredIResourceBuilder<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. ProxyBlazorTelemetry(IResourceBuilder<ProjectResource>, string)extensionats ignoredIResourceBuilder<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.