BlazorHostedExtensions Methods
ClassMethods6 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)extensionIResourceBuilder<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
hostIResourceBuilder<ProjectResource> The host resource builder.serviceIResourceBuilder<IResourceWithServiceDiscovery> The service to proxy.apiPrefix stringoptionalThe URL path prefix for API proxy routes. Defaults to "_api" .ProxyBlazorService(IResourceBuilder<T>, IResourceBuilder<IResourceWithServiceDiscovery>, string) Section titled ProxyBlazorService(IResourceBuilder<T>, IResourceBuilder<IResourceWithServiceDiscovery>, string)extensionIResourceBuilder<T> Configures a .NET program host to proxy requests from its WebAssembly client to a service.
public static class BlazorHostedExtensions{ public static IResourceBuilder<T> ProxyBlazorService<T>( this IResourceBuilder<T> host, IResourceBuilder<IResourceWithServiceDiscovery> service, string apiPrefix = "_api") { // ... }}Parameters
hostIResourceBuilder<T> The host resource builder.serviceIResourceBuilder<IResourceWithServiceDiscovery> The service to proxy.apiPrefix stringoptionalThe URL path prefix for API proxy routes.Returns
IResourceBuilder<T> The host resource builder for chaining.ProxyBlazorTelemetry(IResourceBuilder<ProjectResource>, string) Section titled ProxyBlazorTelemetry(IResourceBuilder<ProjectResource>, string)extensionIResourceBuilder<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
hostIResourceBuilder<ProjectResource> The host resource builder.otlpPrefix stringoptionalThe URL path prefix for OTLP proxy routes. Defaults to "_otlp" .ProxyBlazorTelemetry(IResourceBuilder<T>, string) Section titled ProxyBlazorTelemetry(IResourceBuilder<T>, string)extensionIResourceBuilder<T> Configures a .NET program host to proxy OpenTelemetry data from its WebAssembly client.
public static class BlazorHostedExtensions{ public static IResourceBuilder<T> ProxyBlazorTelemetry<T>( this IResourceBuilder<T> host, string otlpPrefix = "_otlp") { // ... }}Parameters
hostIResourceBuilder<T> The host resource builder.otlpPrefix stringoptionalThe URL path prefix for OTLP proxy routes.Returns
IResourceBuilder<T> The host resource builder for chaining.WithBlazorDebuggerBrowser(IResourceBuilder<ProjectResource>, string) Section titled WithBlazorDebuggerBrowser(IResourceBuilder<ProjectResource>, string)extensionIResourceBuilder<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. public static class BlazorHostedExtensions{ public static IResourceBuilder<ProjectResource> WithBlazorDebuggerBrowser( this IResourceBuilder<ProjectResource> host, string browser = "msedge") { // ... }}Parameters
hostIResourceBuilder<ProjectResource> The host resource builder.browserstringoptionalThe browser to use for debugging. Defaults to "msedge". Supported values include "msedge" and "chrome".WithBlazorDebuggerBrowser(IResourceBuilder<T>, string) Section titled WithBlazorDebuggerBrowser(IResourceBuilder<T>, string)extensionIResourceBuilder<T> Configures the browser launched for a hosted Blazor WebAssembly client on a .NET program resource.
public static class BlazorHostedExtensions{ public static IResourceBuilder<T> WithBlazorDebuggerBrowser<T>( this IResourceBuilder<T> host, string browser = "msedge") { // ... }}Parameters
hostIResourceBuilder<T> The host resource builder.browserstringoptionalThe browser to use for debugging.Returns
IResourceBuilder<T> The host resource builder for chaining.