BlazorDualMode icon indicating copy to clipboard operation
BlazorDualMode copied to clipboard

How to bootstrap client services during ServerPrerendered?

Open koliyo opened this issue 4 years ago • 1 comments

I have a client-side Blazor application with a bunch of stuff in Client/Program.cs, setting up some libraries and services. eg

     // Client-side configuration in `Client.Program.Main`
      builder.Services.AddSingleton<MyService>();

      builder.Services
      .AddBlazorise(options => {
        options.ChangeTextOnKeyPress = true;
      })

If I follow this dual mode guide and use

@(await Html.RenderComponentAsync<Client.App>(RenderMode.ServerPrerendered))

Then I do not get these services registered and rendering fails.

How should this be configured?

koliyo avatar Sep 20 '20 14:09 koliyo

@koliyo you can create helper service extension class and register in the the startup.

chhinsras avatar Aug 03 '21 03:08 chhinsras