From 9da4dc960a7905e54d8529453486fdd40623da7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Onur=20P=C4=B1=C3=A7akc=C4=B1?= <98148844+onurpicakci@users.noreply.github.com> Date: Wed, 31 May 2023 13:36:41 +0300 Subject: [PATCH] Blog: added redirect if blog name is null --- .../Volo/Blogging/Blogs/BlogAppService.cs | 5 ----- .../src/Volo.Blogging.Web/Pages/Blogs/Posts/Index.cshtml.cs | 6 ++++++ 2 files changed, 6 insertions(+), 5 deletions(-) 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..4f4bd371ad 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 @@ -33,11 +33,6 @@ namespace Volo.Blogging.Blogs var blog = await BlogRepository.FindByShortNameAsync(shortName); - if (blog == null) - { - throw new EntityNotFoundException(typeof(Blog), shortName); - } - return ObjectMapper.Map(blog); } 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..be1bf5779b 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 @@ -44,6 +44,12 @@ namespace Volo.Blogging.Pages.Blog.Posts } Blog = await _blogAppService.GetByShortNameAsync(BlogShortName); + + if (Blog == null) + { + return RedirectToPage("/Blogs/Index"); + } + Posts = (await _postAppService.GetListByBlogIdAndTagNameAsync(Blog.Id, TagName)).Items; PopularTags = (await _tagAppService.GetPopularTagsAsync(Blog.Id, new GetPopularTagsInput {ResultCount = 10, MinimumPostCount = 2}));