protected void Application_AuthenticateRequest() { // Check if user logged in if (User == null) { return; } // Get username string username = Context.User.Identity.Name; Context.User = null; // declare array of roles string[] roles = null; using (MyBudgetDB db = new MyBudgetDB()) { // populate roles User dto = db.Users.Include(r => r.Roles).FirstOrDefault(x => x.Username == username); roles = dto.Roles.Select(x => x.RoleName).ToArray(); } // Build IPrincipal object IIdentity userIdentity = new GenericIdentity(username); IPrincipal newUserObj = new GenericPrincipal(userIdentity, roles); // Update Context.User Context.User = newUserObj; }