# BlazorHostedExtensions Methods

- Package: [Aspire.Hosting.Blazor](/reference/api/csharp/aspire.hosting.blazor.md)
- Type: [BlazorHostedExtensions](/reference/api/csharp/aspire.hosting.blazor/blazorhostedextensions.md)
- Kind: `Methods`
- Members: `2`

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)

- Name: `ProxyBlazorService(IResourceBuilder<ProjectResource>, IResourceBuilder<IResourceWithServiceDiscovery>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ProjectResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/becb48e2d61099e35ae336d527d3875e928d6594/src/Aspire.Hosting.Blazor/BlazorHostedExtensions.cs#L34-L46)

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.

```csharp
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"`.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.

## ProxyBlazorTelemetry(IResourceBuilder<ProjectResource>, string)

- Name: `ProxyBlazorTelemetry(IResourceBuilder<ProjectResource>, string)`
- Modifiers: `extension`
- Returns: `IResourceBuilder<ProjectResource>`
- Source: [GitHub](https://github.com/microsoft/aspire/blob/becb48e2d61099e35ae336d527d3875e928d6594/src/Aspire.Hosting.Blazor/BlazorHostedExtensions.cs#L62-L68)

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.

```csharp
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"`.

## ATS metadata

### Ignored by ATS

- Excluded from automatic Polyglot export.
