Update clientcontext object on change in site address in c# winforms

101 Views Asked by At

I am trying to connect SharePoint from C# windows forms application. I am able to connect to SharePoint but after getting connected to SharePoint site If I decide to connect to some other site and change the site address at clientcontext.Executequery() it gives error as "Incorrect username or password" though both of them are correct.

1

There are 1 best solutions below

0
On

Make sure you init the clientcontext with target site, can't use it cross site.

using (var clientContext = new ClientContext("url1"))
            {
                clientContext.Credentials= new NetworkCredential("user", "password", "companydomain");