public override string[] GetRolesForUser(string username) { if (!HttpContext.Current.User.Identity.IsAuthenticated) { return(null); } //check cache var cacheKey = string.Format("{0}_role", username); if (HttpRuntime.Cache[cacheKey] != null) { return((string[])HttpRuntime.Cache[cacheKey]); } string[] roles = new string[] { }; using (FlowerShopOnline db = new FlowerShopOnline()) { roles = db.Users.Where(x => x.Username == HttpContext.Current.User.Identity.Name).Select(x => x.Role.Name).ToArray(); if (roles.Count() > 0) { HttpRuntime.Cache.Insert(cacheKey, roles, null, DateTime.Now.AddMinutes(_cacheTimeoutInMinute), Cache.NoSlidingExpiration); } } return(roles); }