Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error - Cannot contact site at the specified URL. There is no Web named "*.asmx"

I am trying a read all the documents folder and subfolder from a share point website using Microsoft.SharePoint.Client.dll. This is the code which i am using for this:-

static void Main(string[] args)
        {
        string siteUrl = @"http://servername/sites/subfolder/default.aspx";
        ClientContext clientContext = new ClientContext(siteUrl);
        Web site = clientContext.Web;
        FolderCollection collFolder = site.Folders;
        clientContext.Load(collFolder);
        clientContext.ExecuteQuery();
        Console.WriteLine("The current site contains the following folders:\n\n");
        foreach (Folder myFolder in collFolder)
            Console.WriteLine(myFolder.Name);
        }

While debugging i am getting the below error on clientContext.ExecuteQuery(); code. Error-

Cannot contact site at the specified URL http://servername/sites/subfolder/default.aspx. There is no Web named "/sites/subfolder/default.aspx/_vti_bin/sites.asmx".

Please help me to fix this as i am new to the sharepoint and already googled alot on this error but not able to fix it.

Thanks in Advance for all the Coders .

like image 886
Dharmendra Kumar Singh Avatar asked May 19 '14 13:05

Dharmendra Kumar Singh


2 Answers

The problem you are having is that your site path is not specified correctly.

instead of

string siteUrl = @"http://servername/sites/subfolder/default.aspx";

try

string siteUrl = @"http://servername/";

if that doesnt work, use whatever address you can enter into your browser of choice to get the site to load.

like image 89
iamkrillin Avatar answered Oct 31 '22 22:10

iamkrillin


There must be some error code statement in web.config of your application.

Try changing SessionState mode from InProc to SQLServer.

example:

comment this in your web.config

<sessionState mode="InProc" cookieless="AutoDetect" timeout="20" />

and use something like this in your web.config as per your database

<sessionState mode="SQLServer" timeout="60" allowCustomSqlDatabase="true" sqlConnectionString="Data Source=db;Initial Catalog=MyTestDB_j34b37c3674f46afa09chgsd278a35fa;Integrated Security=True;Enlist=False;Connect Timeout=15" />
like image 29
Sid M Avatar answered Oct 31 '22 22:10

Sid M