babaktaremi / GoogleCaptchaComponent

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

get problem in net 8 blazor app #14

Closed Lanticee closed 8 months ago

Lanticee commented 8 months ago

Hi I get problem like:

fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111] Unhandled exception in circuit 'oKmMBwh2APa4nUbjvlq-2acfZQrOz0vprhh7dBPGHFk'. System.InvalidOperationException: Headers are read-only, response has already started. at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpHeaders.ThrowHeadersReadOnlyException() at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseHeaders.Microsoft.AspNetCore.Http.IHeaderDictionary.set_SetCookie(StringValues value) at Microsoft.AspNetCore.Http.ResponseCookies.Append(String key, String value, CookieOptions options) at Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager.AppendResponseCookie(HttpContext context, String key, String value, CookieOptions options) at Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler.HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties) at Microsoft.AspNetCore.Authentication.AuthenticationService.SignInAsync(HttpContext context, String scheme, ClaimsPrincipal principal, AuthenticationProperties properties) at Microsoft.AspNetCore.Identity.SignInManager1.SignInWithClaimsAsync(TUser user, AuthenticationProperties authenticationProperties, IEnumerable1 additionalClaims) at AppCore.Web.Components.Logins.Login.LoginUser() in D:\mstech\AppCore\src\AppCore.Web\Components\Logins\Login.razor:line 155 at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.Forms.EditForm.HandleSubmitAsync() at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task) at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

If i try use SignInManager.SignInWithClaimsAsync, I got error.

babaktaremi commented 8 months ago

Hi

I get problem like:

fail: Microsoft.AspNetCore.Components.Server.Circuits.CircuitHost[111]

  Unhandled exception in circuit 'oKmMBwh2APa4nUbjvlq-2acfZQrOz0vprhh7dBPGHFk'.

  System.InvalidOperationException: Headers are read-only, response has already started.

     at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpHeaders.ThrowHeadersReadOnlyException()

     at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpResponseHeaders.Microsoft.AspNetCore.Http.IHeaderDictionary.set_SetCookie(StringValues value)

     at Microsoft.AspNetCore.Http.ResponseCookies.Append(String key, String value, CookieOptions options)

     at Microsoft.AspNetCore.Authentication.Cookies.ChunkingCookieManager.AppendResponseCookie(HttpContext context, String key, String value, CookieOptions options)

     at Microsoft.AspNetCore.Authentication.Cookies.CookieAuthenticationHandler.HandleSignInAsync(ClaimsPrincipal user, AuthenticationProperties properties)

     at Microsoft.AspNetCore.Authentication.AuthenticationService.SignInAsync(HttpContext context, String scheme, ClaimsPrincipal principal, AuthenticationProperties properties)

     at Microsoft.AspNetCore.Identity.SignInManager`1.SignInWithClaimsAsync(TUser user, AuthenticationProperties authenticationProperties, IEnumerable`1 additionalClaims)

     at AppCore.Web.Components.Logins.Login.LoginUser() in D:\mstech\AppCore\src\AppCore.Web\Components\Logins\Login.razor:line 155

     at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)

     at Microsoft.AspNetCore.Components.Forms.EditForm.HandleSubmitAsync()

     at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)

     at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

If i try use SignInManager.SignInWithClaimsAsync, I got error.

Hi This error is not related to captcha component but the SignInManager . Refer to microsoft doc for implementing authentication correctly in Blazor

Lanticee commented 8 months ago

OK THX