コード例 #1
0
        public async Task <string[]> GetAllUrls()
        {
            var urls = new List <string> {
                "/", "/about", "/blog?type=tech", "/blog?type=nontech", "/resume"
            };
            var techLinks = await _blogCache.GetAllLinks(Category.Tech);

            var nonTechLinks = await _blogCache.GetAllLinks(Category.NonTech);

            urls.AddRange(techLinks.Concat(nonTechLinks).Select(x => $"/blog/{x.Slug}"));
            return(urls.ToArray());
        }
コード例 #2
0
        public async Task <IActionResult> Blog(string slug)
        {
            var post = await _blogCache.GetPost(slug);

            if (post == null)
            {
                return(BlogNotFound());
            }

            var sideLinks = await _blogCache.GetAllLinks(post.Category, post.Slug, 15);

            var model = new BlogViewModel {
                Category = post.Category, SideLinks = sideLinks, Post = post
            };

            Response.Headers[HeaderNames.CacheControl] = "no-cache";
            return(View(model));
        }