2
votes

So let's say I have a full url into a sharepoint website.

In the past when I wanted to get the weburl and doc url, I used the "url to web url" method of the Front Page Server Extensions. (http://msdn.microsoft.com/en-us/library/ms460544.aspx).

So for example if you had a site at 
http://webapp/site1/chidsite/a.doc

I want a method in CSOM that will return /site1/childsite as the weburl.

I see the Web.WebUrlFromPageUrlDirect() method in CSOM but I'm not sure I'm getting what I need back from it. In the Uri class I get back, would I use teh "AbsolutePath" property for the weburl?

What is the correct way to do this?

I also would like to get the docURL that is usually retrieved by a call to url to web url via frontpage extensions.

The fileurl will be the file location relative to the web site. So if the document is stored in the document library called "Documents", you will get a value of /Documents/file.ext.

1
There is property ServerRelativeUrl msdn.microsoft.com/en-us/library/…, but I'm not sure if your looking for this, or SiteCollection-relative url. In second case, I think there is no single method to get this information. - Marek Kembrowski
can you specify from above url what do you want ? - Hardik Fefar
I'm pretty sure the Web.WebUrlFromPageURL() direct retrieving a URI and using the "Absolute Path" property on the URI is what I want for the weburl. I just don't know how to get the file url if you give a full path to it. I'll edit the question to ask that part as well - Dan G

1 Answers

0
votes

Well, I've reverted to using the FrontPage extensions when doing URLToWebURL since I just wasn't sure what I was getting using CSOM methods. Though check the link below for answers I received elsewhere.

Information Pertaining to this issue