public ActionResult Index() { IndexViewModel model = new IndexViewModel(); using (var ctx = PnPPartnerPackContextProvider.GetAppOnlyClientContext(PnPPartnerPackSettings.InfrastructureSiteUrl)) { // Track usage of the PnP Partner Pack ctx.ClientTag = "SPDev:PartnerPack"; Web web = ctx.Web; ctx.Load(web, w => w.Title, w => w.Url); ctx.ExecuteQuery(); model.InfrastructuralSiteUrl = web.Url; } var currentUser = UserUtility.GetCurrentUser(); if (currentUser != null) { model.CurrentUserPrincipalName = currentUser.UserPrincipalName; } else { model.CurrentUserPrincipalName = ClaimsPrincipal.Current.Identity.Name; } return(View(model)); }