Connect Sharepoint with c# via PnPCore

31 views Asked by At

I use method GetWebLoginClientContext to access Sharepoint with MFA.

It was perfect since multiple users will use this program and i didn't want user to write any password/got any credential within code for security sake.

This worked for few days then now i got below screen saying that browser needs now to be updated. Is there any workarround ? or other method that do not required any credential ?

public static ClientContext connectToSharepoint(string siteUrl)
{
var authManager = new OfficeDevPnP.Core.AuthenticationManager();
ClientContext context = authManager.GetWebLoginClientContext(siteUrl);
return context; 
}

PopUp showing this

I tried several other method but nothing worked

** SOLVED ** added this code and it worked

    using (var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(
    @"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION",
    true))
    {
    var app = System.IO.Path.GetFileName(Application.ExecutablePath);
    key.SetValue(app, 11001, Microsoft.Win32.RegistryValueKind.DWord);
    key.Close();
    }
1

There are 1 answers

1
Thibault_Km On

Solved : Added this before my code and it worked

    using (var key = Microsoft.Win32.Registry.CurrentUser.OpenSubKey(
    @"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION",
    true))
    {
    var app = System.IO.Path.GetFileName(Application.ExecutablePath);
    key.SetValue(app, 11001, Microsoft.Win32.RegistryValueKind.DWord);
    key.Close();
    }