Inconvenient rootfolder parameter in discussions

Inconvenient rootfolder parameter in discussions header image

As many of you would probably know there are some caveats when working with URL’s in SharePoint. Some documentation will tell you the URL’s are in fact case insensitive, while other information on the internet will let you to believe that in fact are case sensitive and using a wrong casing can result in major issues.

Now as most things in SharePoint the answer to the result of that discussion is: ‘it depends’. If you would enter your URL to your SharePoint environment like:

http://SomeIntranet

While IIS knows your site as

http://someintranet

You would be redirected correctly, without any errors or hassle. However if you would have a wrong casing in your RootFolder when uploading documents might end up in the wrong place, as is proven in

a blog post about SharePoint is Case-Sensitive.

Having that in mind I didn’t take much risks and always used the correct casing in my URL’s having no problem with it. However I recently was called in on a project that had a strange issue: For some of the users of an intranet the reply’s they made on discussions were not stored and posting them didn’t give an error. Now for most of the users their replies showed up perfectly so my first thought was to check the ULS logs to make sure there were no exceptions thrown when posting replies.

Since there was nothing there I moved up to ruling out the usual, but since there was no real pattern I didn’t find much usefully, and was not able to reproduce the error. However at some point it struck me that if there weren’t any errors the replies should be there. So I created a view that actually showed all items (by default a Discussion board list only shows the ContentType Discussion), and all the ‘missing’ replies showed up in the rootfolder instead of the discussion. Since discussions are some sort of folder with extra metadata it all started to make sense. If the wrong URL is used the reply cannot be saved to the correct discussion. So I dug up the IIS logs and checked all the reference URLS.

Now that is where it all started to become a bit frustrating though. Within SharePoint there are two ways to enter a discussion. You could either use:

http://someintranet/list/discussionboard/My%20First%20Discussion

Or you could use the following:

http://someintranet/list/discussionboard/view.aspx?RootFolder=http%3A%2F%2Fsomeintranet%2Flist%2Fdiscussionboard%2FMy%2520First%2520Discussion%20

Both of these URLs will end up serving you with the same discussion. Now in both discussions you would have the reply button allowing you reply to any given question. If you would hit reply you would always end up with an URL that looks like this: http://someintranet/list/discussionboard/NewForm.aspx?RootFolder=http%3A%2F%2Fsomeintranet%2Flist%2Fdiscussionboard%2FMy%2520First%2520Discussion%20&ContentTypeId=0x0107&DiscussionParentID=17

After some playing around the DiscussionParentID I figured it can be safely deleted from the request, as it seems not to be used anywhere. Leaving only the RootFolder parameter there. Now if you would have wrong capitalization there you would end up with replies in the rootfolder instead of the discussion. So while checking the IIS logs for the request that were made and having the ULS logs to check what happened there I managed to figure it out. If you would enter the following URL

http://SOMEINTRANET/list/discussionboard/My%20First%20Discussion two things will happen. Your URL will be translated to the lowercase version that is the correct one but not before a RootFolder parameter is constructed containing the wrong capitalized version of your URL, ending up in something like http://someintranet/list/discussionboard/NewForm.aspx?RootFolder=http%3A%2F%2FSOMEINTRANET%2Flist%2Fdiscussionboard%2FMy%2520First%2520Discussion%20&ContentTypeId=0x0107&DiscussionParentID=17

Now as you can see spotting a difference in the URL above (a wrong one) and the working one above that is quite hard, and since it will not throw an error or log anything about not being able to store to the correct discussion figuring it out took me a bit longer then I wished for. What happens under the head is that SharePoint constructs the rootfolder parameter before it rewrites to the corrected URL this having a ‘wrong’ rootfolder parameter. The logic that constructs the rootfolder also implements some caching thus every time a rootfolder parameter is already present it will take that into account. So once you hit a discussion wrongly (with: http://SOMEINTRANET/list/discussionboard/My%20First%20Discussion you have a wrong RootFolder parameter, and every call from within that discussion board will fail when replying to a discussion.

So whenever you are missing replies in your discussion board make sure to check the rootfolder for replies and make sure you are not reference some wrongly capitalized URL :-).

Loading comments…