-
-
Notifications
You must be signed in to change notification settings - Fork 192
Open
Description
When use Fido2.BlazorWebAssembly in winform + blazor, the following exception thrown:
Cannot invoke JavaScript outside of a WebView context.
Temp solution:
InitializeComponent();
var services = new ServiceCollection();
services.AddWindowsFormsBlazorWebView();
- services.AddWebAuthn();
+ services.AddScoped<WebAuthn>();
services.AddSingleton(new HttpClient()
{
BaseAddress = new("https://localhost:7108/")
});
blazorWebView1.HostPage = "wwwroot\\index.html";
blazorWebView1.Services = services.BuildServiceProvider();
blazorWebView1.RootComponents.Add<App>("#app");
The reason of error is singleton service created before blazor webview ready.
Should import WebAuthn.js in Init() method ?
async Task Init() => js.InvokeAsync<IJSObjectReference>("import", "./_content/Fido2.BlazorWebAssembly/js/WebAuthn.js");
Metadata
Metadata
Assignees
Labels
No labels