title: How to sign out over HttpContext in server-side Blazor
body: <p>I access the <code>HttpContext</code> in a Blazor server-side view to manually log out. I added this line to <code>Startup.cs</code>: <code>services.AddHttpContextAccessor();</code> and inject it in the view with <code>@inject IHttpContextAccessor HttpContextAccessor</code>.
  I've got a log out button which tries to execute this code:</p>
  
  <pre><code>await HttpContextAccessor.HttpContext.SignOutAsync("Cookies");
  </code></pre>
  
  <p>but I get the following error message:</p>
  
  <pre><code>System.InvalidOperationException: 'Headers are read-only, response has already started.'
  </code></pre>
  
  <p>How can I prevent this error?</p>