0
samvh created
Hello,
I have a 'what would be best'-question, I hope you can help me with it.
I'm using a bootstrap topbar and a dropdown div to display the current logged-in user information. This bar and user information should be available on all pages.
What would be the best way to retrieve this information. I'm thinking about 3 solutions:
- Use the ISessionAppService and send GetCurrentLoginInformationsOutput to the shared _Layout view.
- Use the UserManager to obtain the User and store the needed values in a ViewModel that is used in the _Layout.
- Use the User.Identity in _Layout and extend it with the necessary fields.
I assume that 1. and 2. would be done in the ...ControllerBase so that all the Controllers can use the functionality.
Thanks !
2 Answer(s)
-
0
I seperated header to a partial view and calling
@Html.Action("Header", "Layout")
from _Layout.cshtml. And this is the Header action:
[ChildActionOnly] public PartialViewResult Header() { var headerModel = new HeaderViewModel { LoginInformations = AsyncHelper.RunSync(() => _sessionAppService.GetCurrentLoginInformations()), Languages = LocalizationManager.GetAllLanguages(), CurrentLanguage = LocalizationManager.CurrentLanguage, IsMultiTenancyEnabled = _multiTenancyConfig.IsEnabled }; return PartialView("_Header", headerModel); }
Hope it helps :)
-
0
Helped me very much :) Thanks!