aspnetcore: Error Headers are read-only, response has already started .net 8 blazor

Hi, the login page is refreshed because of this i change render mode to InteractiveServer to disable reload page when click submit in login form

but when run this code : var result = await SignInManager.PasswordSignInAsync(Input.Email, Input.Password, Input.RememberMe, lockoutOnFailure: false);

i have this error Headers are read-only, response has already started

my project is Blazor Web App (Auto Interactivity)

you can test login in my project 1.register new user 2.click on confirm email 3.login

ForumProject.zip

what’s is problem ?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 1
  • Comments: 16 (3 by maintainers)

Most upvoted comments

Same issue when using @attribute [StreamRendering] inside a SSR page without interactivity

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 DGAV.Candidatos.Web.Services.AuthenticationManager.SignInWithClaimsAsync(List`1 claims, AuthenticationProperties properties) in C:\ProjectsTFS\DGAF\DGAVCandidatos\DGAV.Candidatos.Web\Services\AuthenticationManager.cs:line 205
   at DGAV.Candidatos.Web.Services.AuthenticationManager.SignInAsync(UserInfo userInfo, Nullable`1 expires) in C:\ProjectsTFS\DGAF\DGAVCandidatos\DGAV.Candidatos.Web\Services\AuthenticationManager.cs:line 191
   at DGAV.Candidatos.Web.Services.AuthenticationManager.GenerateSignInCodeWithTaxNumber(String taxNumber) in C:\ProjectsTFS\DGAF\DGAVCandidatos\DGAV.Candidatos.Web\Services\AuthenticationManager.cs:line 146
   at DGAV.Candidatos.Web.Components.Pages.Authentication.TaxNumberSignIn.HandleSignIn() in C:\ProjectsTFS\DGAF\DGAVCandidatos\DGAV.Candidatos.Web\Components\Pages\Authentication\TaxNumberSignIn.razor:line 85
   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)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.<WaitForQuiescence>g__ProcessAsynchronousWork|54_0()
   at Microsoft.AspNetCore.Components.RenderTree.Renderer.WaitForQuiescence()
   at Microsoft.AspNetCore.Components.Endpoints.EndpointHtmlRenderer.SendStreamingUpdatesAsync(HttpContext httpContext, Task untilTaskCompleted, TextWriter writer)