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 .
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.
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" />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With