Integration of .NET with SharePoint

| By Webner

SharePoint and .NET Integration

Create a .Net Web Api Application and then follow the below steps:

Step 1. Open “Tools” from menu and select “NuGet Package Manager” and then click on “Manage NuGet Packages for Solution”. Here is the screenshot:

Step 2. A new tab will open “NuGet Solution”. From this tab search for the following Packages and install them in your project. Here are the Package names you need to install-

Step 3. After installing these packages you have to write code where you need to give site url, username and password. Here your site url will be like this – “https://[tenent][SiteName]”

OfficeDevPnP.Core.AuthenticationManager authMgr = new OfficeDevPnP.Core.AuthenticationManager();
   	using (var ctx = authMgr.GetSharePointOnlineAuthenticatedContextTenant(_siteUrl, _userId, _password))
   		Web web = ctx.Web;
   		List list = web.Lists.GetByTitle("Documents"); // fetch all the Files/Folders from Document Library.
   		ctx.Load(list); //Load the documents 
	catch (Exception ex)
   	 { …. }

AuthenticationManager manager class is used to obtain a SharePointContext (ctx ) object. In place of password you can also use (System.Security.SecureString _password) to pass secure string.

Leave a Reply

Your email address will not be published. Required fields are marked *