Navigation persists after deleting comment

Topics: Business Logic Layer
May 28, 2008 at 4:24 AM
I posted a test comment on my blog and then deleted it. For some reason, the >> navigation continues to display at the top of the blog. If I click on it, i get an "Oops! I can't find the page you're looking for" page. Has anyone seen this? Any ideas why this is happening?

Thanks....Ken
Jun 17, 2008 at 9:31 PM
I had this same problem, what I did to fix it is below:

Edit post.aspx.cs from the root folder of you BE install

Find the GetNextPost function around line 76. The things I added in are in red.

       private Post GetNextPost(Post post)

      {

            if (post.Next == null || post.Next.IsDeleted)

                  return null;

 

            if (post.Next.IsVisible || Page.User.IsInRole("administrators") || Page.User.Identity.Name == post.Next.Author)

                  return post.Next;

 

            return GetNextPost(post.Next);

      }

 

      /// <summary>

      /// Gets the prev post filtered for invisible posts.

      /// </summary>

      private Post GetPrevPost(Post post)

      {

            if (post.Previous == null || post.Previous.IsDeleted)

                  return null;

 

            if (post.Previous.IsVisible || Page.User.IsInRole("administrators") || Page.User.Identity.Name == post.Previous.Author)

                  return post.Previous;

 

            return GetPrevPost(post.Previous);

      }

 

      /// <summary>

      /// Inits the navigation links above the post and in the HTML head section.

      /// </summary>

      private void InitNavigationLinks()

      {

            if (BlogSettings.Instance.ShowPostNavigation)

            {

                  Post next = GetNextPost(Post);

                  Post prev = GetPrevPost(Post);

            if (next != null || prev != null)

            {

                if (next != null)

                {

                    hlNext.NavigateUrl = next.RelativeLink;

                    hlNext.Text = Server.HtmlEncode(next.Title + " >>");

                    hlNext.ToolTip = Resources.labels.nextPost;

                    base.AddGenericLink("next", Post.Next.Title, Post.Next.RelativeLink.ToString());

                }

 

                if (prev != null)

                {

                    hlPrev.NavigateUrl = prev.RelativeLink;

                    hlPrev.Text = Server.HtmlEncode("<< " + prev.Title);

                    hlPrev.ToolTip = Resources.labels.previousPost;

                    base.AddGenericLink("prev", Post.Previous.Title, Post.Previous.RelativeLink.ToString());

                }

 

                phPostNavigation.Visible = true;

            }

         }

      }

This post is a bit old, but I figured if I was having this problem, I would think others are as well, so hopefully it'll help somebody.

Jun 17, 2008 at 11:40 PM
I'm sure the fix will solve the problem. But I have different solution here by changing the logic when deleting post. Deleting post should remove the post from the Posts cache, and relinks all posts. Therefore all next and prev links will be updated based on the current condition of the Posts cache.

Regards,
Agus Suhanto