Skip to content

Configuring Lazy Loading @ Server

Ivan Sanz Carasa edited this page May 1, 2020 · 5 revisions

The following nuget package includes everything you need to support lazy loading on Blazor Server and Prerendering.

It can be installed by adding the following line inside the host csproj:

<PackageReference Include="BlazorLazyLoading.Server" Version="1.0.0" PrivateAssets="all" />

It will also require to be initialized from Startup.cs by adding the following lines:

public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {
        services.AddLazyLoading(new LazyLoadingOptions
        {
            ModuleHints = new[] { "ModulesHost" }
        });
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        // ideally after calling app.UseStaticFiles()
        app.UseLazyLoading(); // serves DLL and PDB files as octet/stream
    }
}

LazyLoadingOptions

  • ModuleHints

    Specifies a list of Module Names (hints) to:

    • Download DLLs from them
    • Use their manifest to locate lazy resources
  • UseAssemblyIsolation

    x