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, 7:38 PM
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 11, 2021, 3:32 AM
Thanks for sharing. But i don't know what is result property? Please support me!
Rosli AbdullahPosted Jun 30, 2020, 11:36 PM
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, 7:03 AM
I think package assembly not match with current version or not added in dependency section.
PawanPosted Dec 11, 2019, 2:55 PM
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, 10:52 AM
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 28, 2016, 2:12 AM
Thanks for sharing.