Call WinFormsWebView2 as if it were a class library project (dll) and not an executable (exe). #126
-
Always assuming it is possible, how can I write this code? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi @gguaita 👋 In that sample, the In // Form1.cs
OidcClient _oidcClient;
var options = new OidcClientOptions
{
Authority = "https://demo.duendesoftware.com",
ClientId = "interactive.public",
Scope = "openid email api offline_access",
RedirectUri = "http://localhost/winforms.client",
Browser = new WinFormsWebView()
};
_oidcClient = new OidcClient(options); The // Form1.cs
private async void Login()
{
LoginResult loginResult;
try
{
loginResult = await _oidcClient.LoginAsync();
}
catch (Exception exception)
{
Output.Text = $"Unexpected Error: {exception.Message}";
return;
}
...
} When you call How you then handle the login result is up to you (although the sample does include some handling already). Hope that helps! 😊 |
Beta Was this translation helpful? Give feedback.
Hi @gguaita 👋
In that sample, the
WinFormsWebView2.WinFormsWebView
class does all the work to create the modal form and display aWebView2
component that shows the login UI you interact with, but it is referenced by Form1, it doesn't call Form1.In
Form1.cs
you create and set up an OIDC client that theWinFormsWebView
class gets passed to as part of the client options.