diff --git a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs index ee379959dc..a65d92db30 100644 --- a/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs +++ b/modules/blogging/src/Volo.Blogging.Application/Volo/Blogging/Blogs/BlogAppService.cs @@ -32,7 +32,7 @@ namespace Volo.Blogging.Blogs Check.NotNullOrWhiteSpace(shortName, nameof(shortName)); var blog = await BlogRepository.FindByShortNameAsync(shortName); - + if (blog == null) { throw new EntityNotFoundException(typeof(Blog), shortName); diff --git a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml.cs b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml.cs index 2340d16917..b6cc33034a 100644 --- a/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml.cs +++ b/modules/blogging/src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml.cs @@ -1,7 +1,9 @@ +using System; using System.Collections.Generic; using System.Threading.Tasks; using Microsoft.AspNetCore.Mvc; using Volo.Abp.AspNetCore.Mvc.UI.RazorPages; +using Volo.Abp.Domain.Entities; using Volo.Blogging.Blogs; using Volo.Blogging.Blogs.Dtos; using Volo.Blogging.Pages.Blogs.Shared.Helpers; @@ -43,7 +45,15 @@ namespace Volo.Blogging.Pages.Blog.Posts return NotFound(); } - Blog = await _blogAppService.GetByShortNameAsync(BlogShortName); + try + { + Blog = await _blogAppService.GetByShortNameAsync(BlogShortName); + } + catch (EntityNotFoundException) + { + return RedirectToPage("/Blogs/Index"); + } + Posts = (await _postAppService.GetListByBlogIdAndTagNameAsync(Blog.Id, TagName)).Items; PopularTags = (await _tagAppService.GetPopularTagsAsync(Blog.Id, new GetPopularTagsInput {ResultCount = 10, MinimumPostCount = 2}));