Dependency Injection in the Blazor UI
Registering Services
var builder = WebAssemblyHostBuilder.CreateDefault(args);
var apiEndpoint =
builder.Configuration["ApiEndpoint"]
?? throw new InvalidOperationException("ApiEndpoint not set");
var result = await builder.BuildBloqsUserInterface(
apiEndpoint,
SampleAppDeclaration.GetTypes(),
AppConstants.App.Name
);
// Register your custom service
builder.Services.AddSingleton<MyCustomService>();Using Services in Command Handlers
Using Services in Blazor Components
Key Points
Last updated