I am new to Razor Pages. I have just one page, I have Index.cshtml and Index.cshtml.cs with
public class IndexModel : PageModel
There is also _Layout.cshtml.
I need to get username from HttpContext Header. and show username in _Layout.cshtml (there is navigation bar).
But I do not get where is the best place to put this code in Razor Pages?
I cannot put it into Index.cshtml.cs OnGet, because I need in Layout, at least I think so.
This is outside this question, but FYI I use Azure Easy Auth and from documentation (and also other non Razor Pages projects) I see that HttpContext.Request.Headers["X-MS-CLIENT-PRINCIPAL-ID"] would contain Name I need.