Finding site and web from URL using the SharePoint client API

20 views Asked by At

What would be the best approach for finding out the site and web if all we have is a URL? The problem is, it can be multiple things:

  1. https://foo.bar/Library/file.png: a file living in the https://foo.bar/ site and the / web
  2. https://foo.bar/subsite/Library/file.png: site https://foo.bar/, web /subsite
  3. https://foo.bar/subsite1/subsite2/Library/file.png: site https://foo.bar/, subsite /subsite1/subsite2/
  4. etc, etc

So, essentially, what I am asking is: what would be the best approach/algorithm for, given a ClientContext (or some other client API), allowing me to figure out the site and the web where the file lives. From there I should be able to easily access the library and the file itself. Looking for .NET-based approach, if possible.

0

There are 0 answers