locked
How to talk from @Body to Layout RRS feed

  • Question

  • User-1771888428 posted

    I want each time user Logs in, Its authentication details load and display in its Layout, The login page is in a separate page thus is @Body and the GetAuthenticationDetails() method is in the Layout page that I want be called after user logins. How to do that?

    Saturday, June 8, 2019 2:49 PM

Answers

  • 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.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, June 10, 2019 7:06 PM