============
Blazor
============
`ASP.NET Core Blazor `_ uses the generic app hosting in ASP.NET Core 3+ but the two `hosting models `_ have slightly different integrations.
**Server-side** implementations are configured in exactly the same way as any other `ASP.NET Core 3 `_ application.
**Client-side** injection is slightly more restricted due to requirements for `WebAssembly `_ hosting.
This example for WebAssembly works as of March 30, 2021 with .NET 5.
Example:
.. sourcecode:: csharp
public class Program
{
public static async Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.ConfigureContainer(new AutofacServiceProviderFactory(ConfigureContainer));
builder.RootComponents.Add("#app");
await builder.Build().RunAsync();
}
private static void ConfigureContainer(ContainerBuilder builder)
{
// add any registrations here
}
}
Once registered, Blazor components can use `dependency injection `_ via the `standard @inject Razor directive `_.