2

I have an Azure ASP.Net Web site. In page load event, creating SharePoint Client Context using Azure AD Application.

Page keeps on loading and after some time shows page timeout exception. Using below code to create SharePoint Client Context. This code is working in console application but not in ASP.Net page. Please let me know how to fix this.

public static ClientContext GetClientContextFromrAzureApp(string siteURL, X509Certificate2 CertApp)
{
    string tenantId = "dbc1c245-33df-411f-a421-...";
    string ClientId = "7f4ff27b-4200-4cba-a666-....";// Azure AD Application ID

    using (var manager = new PnP.Framework.AuthenticationManager(ClientId, new X509Certificate2(CertApp), tenantId, "", AzureEnvironment.USGovernmentHigh))
{
    manager.ClearTokenCache();
    return manager.GetContext(siteURL);
}

}
Vivek
  • 31
  • 4
  • What do you think about this topic: [How to authenticate our .NET console application against SharePoint online if we have `DisableCustomAppAuthentication` set to true](https://stackoverflow.com/questions/68814997/how-to-authenticate-our-net-console-application-against-sharepoint-online-if-we/68964867#68964867). Here contains more details of authentication lifecycle, capturing Token before get ClientContext object. – Antonio Leonardo Aug 30 '21 at 12:47
  • @Vivek- did you get any solution for this? – nbi Jul 12 '23 at 16:51

0 Answers0