public static Guid GetUserId() { if (HttpContext.Current != null && HttpContext.Current.User.Identity.IsAuthenticated && LoginUser.GetUserName() != "") { try { Guid userId = Guid.Empty; HttpCookie UserCookie = new HttpCookie("User"); UserCookie = HttpContext.Current.Request.Cookies["User"]; if (UserCookie != null) { string user = UserCookie.Value.ToString(); user = user.DecryptData(); userId = new Guid(user); } else { AVOAIALifeEntities entities = new AVOAIALifeEntities(); string UserName = LoginUser.GetUserName(); var user = entities.tblUserDetails.FirstOrDefault(a => a.LoginID == UserName); if (user == null) { return(new Guid()); } userId = new Guid(user.UserID.ToString()); } return(userId); } catch (Exception ex) { return(new Guid()); } } else { return(new Guid()); } }