I'm adding a very simple XsltListViewWebPart to an application page. Like so:
XsltListViewWebPart lvWebPart = new XsltListViewWebPart { ChromeType = PartChromeType.None, ListUrl = "/somesite/list" };
Page.Controls.Add(lvWebPart);
Everything works fine (I can download files, create folders, choose different views, etc.) - but the links of folders have the wrong href: they always point to the root web!
See these examples:
As you can see, the document correctly links to ../sites/sr/doclib/mydocument.docx however when looking at the folders they forget the context they are currently in (they are in http://../sites/sr/_layouts/../../..Detail.aspx?RootFolder=...
, the important part being /sites/sr/). They try to go to the _layouts folder in the root site collection context -as shown above: http://../_layouts/../../..Detail.aspx?RootFolder=...
Or again summarized:
- The application page location:
http://sp/sites/sr/_layouts/my/application/Detail.aspx
- The list/doclib I'm accessing
http://sp/sites/sr/mylist
- The URL for folders inside XsltListViewWebPart
http://sp/_layouts/my/application/Detail.aspx?RootFolder=...
- The URL for folders as they should be
http://sp/sites/sr/_layouts/my/application/Detail.aspx?RootFolder=...
Here comes the kicker: When using a ListViewWebPart, everything works like it should! So instead of the XsltListViewWebPart above I just use a ListViewWebpart - and folders work, the context is taken into account the the folders have the URL like I want (http://../sites/sr/_layouts/../../..Detail.aspx?RootFolder=...
I tried setting the WebId Property on the XsltListViewWebpart hoping it would set the context, but no luck. I'm now thinking that either I configure it wrongly or the new SharePoint 2010 XsltListViewWebPart has a bug - as the same code works for a ListViewWebPart on the same Application page.
I hope somebody can verify this issue.