User-821857111 posted
One way you can do this is to create a class that derives from LayoutComponentBase and add a static property e.g.
public class MyLayout : LayoutComponentBase
{
public static string UserName { get; set; }
}
Have your MainLayout inherit from that instead of LayoutComponentBase, and then you can set the value of MyLayout.UserName wherever you like in the application. You can render @UserName in the MainLayout as required.