BlazorHostedExtensions
Classstaticnet10.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{ // ...}6 members
Methods6
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. ProxyBlazorService(IResourceBuilder<T>, IResourceBuilder<IResourceWithServiceDiscovery>, string) extensionats ignoredIResourceBuilder<T> Configures a .NET program host to proxy requests from its WebAssembly client to a service.
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. IResourceBuilder<T> Configures a .NET program host to proxy OpenTelemetry data from its WebAssembly client.
IResourceBuilder<ProjectResource> Configures the browser launched when starting a debug session for the hosted Blazor WebAssembly client. The value is read when the debugger is registered on the first
BlazorHostedExtensions.ProxyBlazorService or BlazorHostedExtensions.ProxyBlazorTelemetry call, so call this before proxying to guarantee it takes effect. IResourceBuilder<T> Configures the browser launched for a hosted Blazor WebAssembly client on a .NET program resource.