Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
using HttpTracer;
using System.Net.Http;
using Microsoft.AspNetCore.Components.Browser;
using Microsoft.AspNetCore.Components.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.AspNetCore.Components;
using System;
using Microsoft.AspNetCore.Blazor.Services;
using Microsoft.AspNetCore.Blazor.Http;
namespace WebApplication1
public class Startup
public void ConfigureServices(IServiceCollection services)
services.AddSingleton<HttpClient>(s =>
// Creating the URI helper needs to wait until the JS Runtime is initialized, so defer it.
var uriHelper = s.GetRequiredService<IUriHelper>();
return new HttpClient(new HttpTracerHandler(new WebAssemblyHttpMessageHandler()))
BaseAddress = new Uri(WebAssemblyUriHelper.Instance.GetBaseUri())
public void Configure(IComponentsApplicationBuilder app)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment