[Update] Ah geez, look at that formatting. Whoops. [/update]
So I get an email from Kevin last night basically saying “dude, the CommentAPI code you added to the CS core sucks; fix it.” Ok, that’s entirely untrue; it was more like
“there was a late change to the CS core that introduced a regression into the CommentAPI subsystem, here’s the culprit, and here’s a quick fix.” Yeah, more like that :-).
I am partially to blame actually; with the release of CS2.0 all httpHandlers were moved out of the web.config file and into .ashx files (which rock by the way, will be posting about this subject very soon) for various reasons, namely for the sake of simplicity and consistency. Apparently I didn’t get that memo (which really means I haven’t been reading my Vault check-in emails to keep up with what’s going on), so my lone httpHandler was left in the config file to intercept incoming CommentAPI posts. As stated before, there was a change in the SiteUrls.config file that intercepted the same url pattern and rewrote it, so those requests were never actually getting fired off to the RssCommentHandler httpHandler. So, here’s the “quick and dirty” fix, via his email to me:
Jayson added Comment API support in early October. He setup the HttpHandler to accept urls like rsscomment/[PostID].aspx and added a line to the Web.config HttpHandlers section to map those requests to it like this:
<add verb="POST" path = "rsscomments/*.aspx" type="CommunityServer.Blogs.Components.RssCommentHandler, CommunityServer.Blogs" />
However at some point after that a second ShortLink SiteUrl was added that intercepts the CommentAPI requests and rewrites the URL before the HttpHander runs.
<url name = "blog_ShortLink2" location = "weblogs" path = "{0}.aspx" pattern = "##blogName##/(\d+).aspx" vanity = "shortlink.ashx?PostID=$2" />
We agreed that the easiest fix is just to comment out the blog_ShortLink2 element in SiteUrls.config; according to Scott this was used for some edge cases and generally speaking shouldn’t affect out of the box installs (YMMV, test first). If that’s good enough for you, you can safely stop reading this post.
The long term solution (getting the httpHandler declaration out of the web.config file) is slightly more involved, but still relatively simple to do (though it does involve recompiling the CSBlogs assembly). The first step is to modify your CommunityServer.Blogs.Components.RssCommentHandler:
Change the default constructor's access level to public (private constructors and ashx files don't get along at all, this took me a little while to figure out but is essential in hooking up ashx's to httpHandlers).
Change line 39 to int postID = int.Parse(request.QueryString["postid"]);
Next we have to change the url handler for rssComments; in SiteUrls.config find the declaration for weblogRssComments and change it to the following: <url name = "weblogRssComments" location = "weblogs" path = "##blogdirectory##rsscomments.aspx?PostID={1}" pattern = "##blogName##/rsscomments.aspx" vanity="rsscomments.ashx?App=$1" />. This hooks up requests for the httpHandler to the ashx file (the ashx stub files are already in correct locations, so there's no need to create these). And finally, remove the httpHandler declaration for rssComments from your web.config. Recompile and you should be good to go. The same steps can be applied to CSGalleries to get CommentAPI properly functioning for them.
As any developer knows, regressions are the toughest bugs of all to track down, so kudos to Kevin's sleuthing work in tracking down the culprit, and my bad for not hooking up those ashx files in the first place.



No comments yet