Search code examples
c#asp.net-coreblazor

Struggling to understand how shared layouts and references are picked up and shared scross pages


I have a blazor server project. I would like to know A) how the shared layout folder works B) now css files and js files are shared across pages. I can see in my project the shared layout but what I want to kow specifically is how is Blazor able to pick up shared resources.

I cannot see any reference calling them in my razor pages.

Please help? I am a bit lost


Solution

  • There is nothing special about that folder.

    The connections are:

    • in _Imports.razor there is a line that makes the layout namespace (folder) accessible:

    @using AppName.Layout

    • and in App.razor or Routes.razor the layout is specified:

    <RouteView RouteData="@routeData" DefaultLayout="@typeof(MainLayout)" />