I have developed a code in CSOM(Client Side Object Module) using c# where before performing any operation on the list I want to check whether the list is null or not? In SSOM we can check that by

.TryGetList() method

how I can achieve the same in CSOM.

if(list!= null){....} is not working as it always goes into the if condition and throws the error in context.Update()

Is there any other way to achieve this without putting the

if(list!= null){....} into try-catch.

2 Answers 2


Nope, it doesn't exist in native CSOM, but the PnP Core library has this extension method:

 if (ctx.Web.ListExists("My List")){
            //do something



You can check the list collection count to see if the list exists in the site as shown below:

           ListCollection listCollection = clientContext.Web.Lists; 
           clientContext.Load(listCollection, lists => lists.Include(list => list.Title).Where(list => list.Title == "ListName"));


            if (listCollection.Count > 0)
                Response.Write("List  exists...");
                Response.Write("List does not exist");
  • It's not happening. Still its goes into the loop and gives error. Aug 3, 2017 at 4:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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