To use SharePoint document or any other information ,data in asp.net you'll authenticate from SharePoint online server following these step.
Step 1 - Use NameSpace "using Microsoft.SharePoint.Client;" after adding reference in your application.
PM> Install-Package Microsoft.SharePoint.Client.dll
Step 2 - Write code to authenticate from SharePoint in asp.net.
- string userName = Your username;
- string password = Your password;
- string baseurl = "Sharepoint base URL";
- Uri uri = new Uri(baseurl);
- var securePassword = new SecureString();
- foreach (var c in password) { securePassword.AppendChar(c); }
- var credentials = new SharePointOnlineCredentials(userName, securePassword);
- var authCookie = credentials.GetAuthenticationCookie(uri);
- var fedAuthString = authCookie.TrimStart("SPOIDCRL=".ToCharArray());
- if (fedAuthString != null)
- {
- result.UserToken = fedAuthString;
- result.Message = "User has been logged in successfully";
- }
- else
- {
- result.Message = "Invalid User!!";
- }
After login you can get any information from SharePoint server which is authorized for this user.


Guido PawlukPosted Sep 27, 2021, 3:38 PM EDT
result does not exist in the current context // If (fedAuthString != null) { result.UserToken = fedAuthString; result.Message = "User has been logged in successfully"; } else { result.Message = "Invalid User!!"; }
kien hvPosted Jan 10, 2021, 10:32 PM EST
Thanks for sharing. But i don't know what is result property? Please support me!
Rosli AbdullahPosted Jun 30, 2020, 7:36 PM EDT
Could not install package 'Microsoft.SharePoint.Client.dll 15.0.4420.1017'. You are trying to install this package into a project that targets '.NETFramework,Version=v4.6.1', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author. 0
Bikesh SrivastavaPosted Dec 12, 2019, 2:03 AM EST
I think package assembly not match with current version or not added in dependency section.
PawanPosted Dec 11, 2019, 9:55 AM EST
I have installed latest version from Install-Package https://www.nuget.org/packages/Microsoft.SharePointOnline.CSOM/16.1.19515.12000 but still it gives run time error " Could not load file or assembly 'Microsoft.SharePoint.Client.Runtime, Version=16.1.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified."
PawanPosted Jun 5, 2019, 6:52 AM EDT
I am able to build the project but it gives runt time error "Could not load file or assembly 'Microsoft.SharePoint.Client.Runtime, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. The system cannot find the file specified."
Tarun DPosted Jul 27, 2016, 10:12 PM EDT
Thanks for sharing.