protected void Page_Load(object sender, EventArgs e) { // If the user hasn't selected a category, display a list of categories // If the user has selected a category, display all videos in that category // Always list categories VideoCategoryRepository videoCategoryRepo = new VideoCategoryRepository(); List <VideoCategory> VideoCategories = videoCategoryRepo.GetTopLevel(); litCategories.Text = addMenuChildren(VideoCategories); // If given a category ID, display all videos from that category if (!string.IsNullOrEmpty(Request.QueryString["category"])) { string parsedCatID = Sanitizers.SanitizeGeneralInputString(Request.QueryString["category"].ToString().Trim()); if (!string.IsNullOrEmpty(parsedCatID)) { VideoCategory selectedCategory = videoCategoryRepo.Get(parsedCatID); if (selectedCategory != null) { // Determine if the viewer is viewing from inside the network string clientIP = Request.ServerVariables["REMOTE_ADDR"]; bool canUserAccessPrivateContent = Config.CanAccessPrivate(clientIP); VideoRepository videoRepository = new VideoRepository(); List <Video> CategoryVideos = videoRepository.GetFromCategory(selectedCategory, canUserAccessPrivateContent); StringBuilder VideoListHTML = new StringBuilder(); foreach (Video video in CategoryVideos) { VideoListHTML.Append(videoListItem(video)); } litVideos.Text = VideoListHTML.ToString(); } } } }