Skip to content

Instantly share code, notes, and snippets.

@dylanberry
Created May 16, 2019 16:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dylanberry/8cf04c591ebf81f46a197855316012fe to your computer and use it in GitHub Desktop.
Save dylanberry/8cf04c591ebf81f46a197855316012fe to your computer and use it in GitHub Desktop.
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)
{
app.AddComponent<App>("app");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment