Cannot contact site at the specified URL. There is no Web named "*.asmx" error in console application c#

Ashok Kumar 201 Reputation points

I want to get the file from the office 365 share point using user credentials (have full access)
but while executing the program at runtime I'm getting the following error.

For this error I have read this post but not given the proper knowledge.

   Microsoft.SharePoint.Client.ClientRequestException: 'Cannot contact site at the specified URL There is no Web named "/sites/my_files/all Files/_vti_bin/sites.asmx"  

below is my code :

   static void Main(string[] args)  
     string url = "";  
               string folderpath = "";  
               string templocation = @"c:\Downloads\Sharepoint\";  
               Program.DownloadFilesFromSharePoint(url, folderpath, templocation);  
   static void DownloadFilesFromSharePoint(string siteUrl, string siteFolderPath, string localTempLocation)  
               string userName = "";  
               string pswd = "ssssss@1043";  
               SecureString password = new SecureString();  
               foreach (var c in pswd.ToCharArray()) password.AppendChar(c);  
               var ctx = new ClientContext(siteUrl);  
               //ctx.Credentials = new NetworkCredential(userName, password, "");  
               ctx.Credentials = new SharePointOnlineCredentials(userName, password);  
               FileCollection files = ctx.Web.GetFolderByServerRelativeUrl(siteFolderPath).Files;  
               if (ctx.HasPendingRequest)  
                   ctx.ExecuteQuery(); //getting error here : Cannot contact site at the specified URL. There is no Web named "*.asmx"  
               foreach (File file in files)  
                   FileInformation fileInfo = File.OpenBinaryDirect(ctx, file.ServerRelativeUrl);  
                   var filePath = localTempLocation + "\\" + file.Name;  
                   System.IO.FileStream fileStream = new System.IO.FileStream(filePath, System.IO.FileMode.OpenOrCreate, System.IO.FileAccess.ReadWrite, System.IO.FileShare.ReadWrite);  

Suggest me how to achieve this and what is the issue ?

A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,884 questions
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
10,397 questions
0 comments No comments
{count} votes

Accepted answer
  1. RaytheonXie_MSFT 32,241 Reputation points Microsoft Vendor

    Hi @Ashok Kumar
    In your case, the site url should be like The url you connect is the path of the document library but not a site. So the error message said There is no Web named "*.asmx".
    You could change the code in main function like following

      string url= "";  

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful