Today I copied the following code from my book to test my first SharePoint-CSOM application, but I cannot get it to work properly:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.SharePoint.Client;
namespace csom
{
class Program
{
static void Main(string[] args)
{
ClientContext ctx = new ClientContext("http://serverone");
ctx.AuthenticationMode = ClientAuthenticationMode.FormsAuthentication;
FormsAuthenticationLoginInfo loginInfo = new FormsAuthenticationLoginInfo
{
LoginName = "myusername@domain.com",
Password = "mypassword"
};
ctx.FormsAuthenticationLoginInfo = loginInfo;
Site site = ctx.Site;
ctx.Load(site);
Web web = site.RootWeb;
ctx.Load(web);
List list = web.Lists.GetByTitle("Project types");
ctx.Load(list);
ctx.ExecuteQuery();
}
}
}
The following exception is thrown and I really cannot find the reason for this. I enabled FormAuthentication in the Central Administration and in IIS for this Website so this cant be the problem...
An unhandled exception of type 'System.Web.Services.Protocols.SoapException' occurred in System.Web.Services.dll
Additional information: Server was unable to process request. ---> The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.
Any idea what I could still try? Of course the values for servers and passwords are changed in this post :)
I googled how to turn on this attribute, and I figured that I have to change my web.config as follows:
<system.serviceModel>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" />
<behaviors>
<serviceBehaviors>
<behavior name="debug">
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<services>
<service name="Microsoft.SharePoint.Client.dll" behaviorConfiguration="debug" />
</services>
</system.serviceModel>
However, this does not work. How can I turn on includeExceptionDetailInFaults in this case?
Thanks
IncludeExceptionDetailInFaults– Aziz Kabyshev Mar 16 '16 at 20:54