babaktaremi / GoogleCaptchaComponent

🤖 Implementation of google reCaptcha as a blazor component with support of reCaptcha-V2 and reCaptcha-V3 and server validation
MIT License
78 stars 16 forks source link

Does not work with dotnet 8 #18

Closed r-work closed 6 months ago

r-work commented 6 months ago

Creating a project with the latest dotnet 8 template, it doesn't show recaptcha. No error messages, it just doesn't show.

Repro repository: https://github.com/r-work/RecaptchaDotnet8.git

babaktaremi commented 6 months ago

Because the google captcha needs to be loaded on the client side . In static server render mode the resulting components are rendered statically and you can’t wire up event handlers to DOM events . make the following changes:

in program.cs class:

builder.Services.AddRazorComponents()
    .AddInteractiveWebAssemblyComponents();
app.MapRazorComponents<App>()
    .AddInteractiveWebAssemblyRenderMode();

in your home.razor page put the following attribute under @page section

@rendermode InteractiveServer
babaktaremi commented 6 months ago

Hope that issue is solved. Closing it for now. feel free to reopen it if issue still exists