Programmatically determine Parent Web’s Absolute URL from SharePoint Client Object Model ListItem

Ok, after a frustrating while of trying to figure out an easy way to get the FULL (Absolute) URL for a ListItem’s parent web using the SharePoint Client Object Model I discovered one thing for sure: There are an abundance of ways to easily find the ServerRelativeUrl for many objects in the Client OM, but that is not what I needed.

After talking to a co-worker, we finally found an easy way to get the parent web’s absolute URL when dealing with at Client OM ListItem.  The key is looking at the Context.

Assuming that you have a variable called “item” that represents an SP Client OM ListItem, you can get the full URL for the parent web like this:


string parentWebAbsUrl = item.ParentList.ParentWeb.Context.Url;

Sometimes it’s the simple things that get you.  Hope that helps you save some time!  Thanks for reading.

Programmatically determine List Type in SharePoint Client Object Model

If you would like to programmatically determine a List Type in C# using the SharePoint Client Object Model, then all you need to do is compare the list’s BaseTemplate, which is an integer identifier, to one of the ListTemplateType enumeration values—casting it to an int as seen below:

bool isDocumentLibrary ;
using (ClientContext clientContext = new ClientContext(baseSiteUrl))
    Web web = clientContext.Web;
    List list = clientContext.Web.Lists.GetByTitle(listName);

    if (list.BaseTemplate == (int)ListTemplateType.DocumentLibrary)
        isDocumentLibrary = true;


That’s all there is to it.  Now you can take this and modify it in any way that you need to make list type determination more dynamic, if you aren’t just needing to compare to a single ListTemplateType as shown above.