title: The URL <filename> is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web
body: <p>I am using <code>Microsoft.SharePoint.Client</code> to work with SharePoint 2013 files in asp.net MVC project. I am able to load file then execute the query but after loading, I have to checkout file. On checkout I am getting following error:</p>
  
  <blockquote>
    <p>The URL is invalid. It may refer to a nonexistent file or folder, or refer to a valid file or folder that is not in the current Web.</p>
  </blockquote>
  
  <p>I created this file via asp.net MVC project only. its fine while creating a file on Sharepoint via code. I also checked out that file from SharePoint directly. It's working fine there. </p>
  
  <p>Note:- File which needs to be checkout is under subsite. </p>
  
  <p>The following is my sample code:</p>
  
  <pre><code> //siteUrl = xxx.com
   //subsite = acct
   //relUrl =  /acct/doclib/test.txt
  using (ClientContext ctx = getContext(siteUrl))
      {
          var site = ctx.Web;
          var file = site.GetFileByServerRelativeUrl(relUrl);
          try
          {
              ctx.Load(file)
              ctx.ExecuteQuery(); 
              if (file.CheckOutType == CheckOutType.None)
              {
                  file.CheckOut();
                  ctx.ExecuteQuery(); // this line is causing error
                  return true;
              }
  </code></pre>