Connect to site from different environment/domain

Updated: Sep 15, 2020

In this blog we will see how to connecting to site from different environment using CSOM with login Credentials

Add two references to your visual studio solution

  • Microsoft.SharePoint.Client.dll &

  • Microsoft.SharePoint.Client.Runtime.dll

string webUri = "http://servername/sites/demo";
using (ClientContext context = new ClientContext(webUri))
        //By Default it will use windows credentials
        //If want to specify credentials use below line
        context.Credentials = new NetworkCredential(

        Web web = context.Web;

        //Load the web object 

        //Web rootWeb = context.Site.RootWeb;

        //call Execute Query 
        //to get all the loaded object working


0 views0 comments

Recent Posts

See All

In this blog we will see how to export a list in excel using server side object model. First block we will retrieve all items from the list. This can be done in several ways. You can get all items wit