!System.InvalidOperationException: The response headers cannot be modified because the response has already started. " in Blazor Server Project

I am getting the error in the folowing line "The response headers cannot be modified because the response has already started.". I am using Blazor server. IS there any solution for this? Is there any configuration In startup.cs file? Please let me know.

await _context.HttpContext.SignInAsync( CookieAuthenticationDefaults.AuthenticationScheme, new ClaimsPrincipal(claimsIdentity), authProperties);

Thanks in Advance Nahar