SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have an own UI for discussion messages. The issue is the Url of the actual SPListItem doesn't help:

SPListItem message = //get message
var url = message.Url; //returns "/Lists/forum/hello/2.000"

What I want is the url "http://contoso/Lists/forum/Flat.aspx?RootFolder=/Lists/forum/hello&CTID=xxx"

This is what I get when I go to a discussion thread.

share|improve this question
up vote 1 down vote accepted

The CTID is the ContentTypeId from the listitem and the rootfolder is ServerUrl from the listitem.

Try this code to see if it gives you the url you want. You could also dynamically get the viewurl if you desire.

var url = "http://contoso/Lists/forum/Flat.aspx?RootFolder=" + message["FileDirRef"] + "&CTID=" + message["ContentTypeId"];
share|improve this answer
Can I get "contoso/Lists/forum/"; generically? – Anatoly Mironov Sep 13 '11 at 13:58
I get ...Flat.aspx?RootFolder=/Lists/forum/hello /2.000 &CTID=xxx2 And therefore I get 404 error – Anatoly Mironov Sep 13 '11 at 14:09
thank you very much Steve. You gave me a awesome hint. Here is the version that I have tested and it really works: var url = message["FileDirRef"] + "?Flat.aspx?RootFolder=" + message["FileDirRef"] + "&CTID=" + message["ContentTypeId"]; Could you update your code in your answer? – Anatoly Mironov Sep 13 '11 at 14:17
Or var url = SPUrlUtility.CombineUrl(argument.List.ParentWeb.Site.Url, message["FileDirRef"] + "?Flat.aspx?RootFolder=" + message["FileDirRef"] + "&CTID=" + message["ContentTypeId"]); – Anatoly Mironov Sep 13 '11 at 14:29
I'm glad you got it working. Yes you can get it generically. From the views collection or calling the defaultviewurl property of the splist. – Steve Lineberry Sep 13 '11 at 16:29

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.