How to access MainLayout object from a rendered page

The MainLayout.razor of my application contains a RadzenTree whose items are RadzenLink that renders pages as @Body when clicked.

I want to make the URL sharable - right now when a URL is copy-n-pasted to a new browser tab, only the @Body portion is rendered and the RadzenTree is lost.

I think one way to fix is for @Body pages to call some method on MainLayout.razor to render RadzenTree, but I cannot find a way to access the MainLayout object from pages displayed as @Body. I tried to use DI injection but that does not work.

So my questions:

  1. What is the right way to make the URLs of a Blazor application sharable.
  2. If I have to go with my way, how to access MainLayout object?

I don't know if this will help, but global variables declared in MainLayout.razor.designer.cs can be accessed by all pages...

SloSuenos

Blazor pages have "shareable" URLs by default. You must have done something wrong with the configuration and the layout is not getting applied to all pages. The layout setting is done usually via the _Imports.razor file:

@layout MainLayout

I believe the static content on MainLayout.razor is fine. Some content on my MainLayout.razor is dynamic (the result of clicking some buttons), so I need to recreate the dynamic content to make the URLs sharable.

Although the MainLayout is not directly accessible, I used a scoped wrapper object to pass around reference to the MainLayout object.