diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-QuotedPoems.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-QuotedPoems.cs index ba9e6784..c22df4cd 100644 --- a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-QuotedPoems.cs +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-QuotedPoems.cs @@ -336,7 +336,11 @@ namespace RMuseum.Services.Implementation var poem2 = await context.GanjoorPoems.AsNoTracking().Where(p => p.FullUrl == poem2Url).SingleOrDefaultAsync(); if (poem2 == null) { - var redirectedPage = await context.GanjoorPages.AsNoTracking().Where(p => p.RedirectFromFullUrl == poem2Url).SingleAsync(); + var redirectedPage = await context.GanjoorPages.AsNoTracking().Where(p => p.RedirectFromFullUrl == poem2Url).SingleOrDefaultAsync(); + if(redirectedPage == null) + { + return new RServiceResult(false, poem2Url); + } poem2 = await context.GanjoorPoems.AsNoTracking().Where(p => p.Id == redirectedPage.Id).SingleAsync(); }