Skip to content

Commit cbd34b9

Browse files
authored
Merge pull request #479 from shanselman/main
comments aren't loaded, null check for /post/guid URLs
2 parents 4b3b2da + 897400e commit cbd34b9

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

azure-pipelines.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ strategy:
55
imageName: 'ubuntu-18.04'
66
# mac:
77
# imageName: 'macos-10.13'
8-
windows:
9-
imageName: 'windows-2019'
8+
# windows:
9+
# imageName: 'windows-2019'
1010

1111
pool:
1212
vmImage: $(imageName)

source/DasBlog.Web.UI/Controllers/BlogPostController.cs

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,21 @@ public IActionResult PostGuid(Guid postid)
9999
var entry = blogManager.GetBlogPostByGuid(postid);
100100
if (entry != null)
101101
{
102-
lpvm.Posts = new List<PostViewModel>() { mapper.Map<PostViewModel>(entry) };
103102

103+
/*
104+
* Very old DasBlog links like
105+
* /PermaLink.aspx?guid=b5790285-2eb7-4198-ac1d-6cfbf20735a4
106+
* turn into
107+
* /post/b5790285-2eb7-4198-ac1d-6cfbf20735a4
108+
* (given correct IISrewrites)
109+
* but fails to render because the Comments are never loaded,
110+
* so you'll get the post but it shows ZERO comments.
111+
* Better to just redirect to the right URL
112+
* I can't figure how to redirect 302 correctly given a /blog baseURL, so for now at least it doesn't break
113+
* and has the right canonical
114+
* //return RedirectToAction("Post", "BlogPost", new { title = lpvm?.Posts?.First().PermaLink });
115+
*/
116+
lpvm.Posts = new List<PostViewModel>() { mapper.Map<PostViewModel>(entry) };
104117
return SinglePostView(lpvm);
105118
}
106119
else

source/DasBlog.Web.UI/Controllers/DasBlogBaseController.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ protected void SinglePost(PostViewModel post)
6262

6363
private void ShowErrors(PostViewModel post)
6464
{
65-
if(post != null && post.Comments.CurrentComment != null && post.ErrorMessages != null && post.ErrorMessages.Count > 0)
65+
if(post != null && post.Comments != null && post.Comments.CurrentComment != null && post.ErrorMessages != null && post.ErrorMessages.Count > 0)
6666
{
6767
foreach(string ErrorMessage in post.ErrorMessages)
6868
{

0 commit comments

Comments
 (0)