title: Blazor Server App - Supporting Windows and Non-Windows Users In The Same App
body: <p>My organization creates apps that must support employees on two entirely separate networks (let's call them network &quot;A&quot; and network &quot;B&quot;). Applications on network &quot;A&quot; must always use Windows Authentication. Since network &quot;B&quot; is entirely separate and therefore cannot have a trust relationship established between the two, the only option is to allow &quot;Anonymous&quot; access and force the user to login in with manual credentials.</p>
  <p>Currently, our Asp.Net apps have both &quot;Anonymous&quot; and &quot;Forms&quot; authentication enabled with a code-behind check of the &quot;LOGON_USER&quot; server variable and if it finds one that maps to a valid Windows Account on network &quot;A&quot;, they are automatically logged in, else they must manually log in.</p>
  <p>In Asp.Net Core, this line of code does not return any value if &quot;Anonymous&quot; authentication is enabled side-by-side with &quot;Windows&quot; authentication:</p>
  <pre><code>@HttpContextAccessor.HttpContext?.GetServerVariable(&quot;LOGON_USER&quot;)
  </code></pre>
  <p>Only when &quot;Windows&quot; is enabled with nothing else do we get a username using the above line of code.</p>
  <p>The key question to ask here is if there is any way at all to maintain the single sign on ability in a Asp.Net Core / Blazor server app so that we do not have to maintain two different versions of the same application? Or is this no longer possible?</p>
  <p>I have read the summation of this article (<a href="https://docs.microsoft.com/en-us/aspnet/core/blazor/security/server/?view=aspnetcore-6.0&amp;tabs=visual-studio" rel="nofollow noreferrer">Secure ASP.NET Core Blazor Server Apps</a>) from Microsoft, and if my interpretation is correct, it unfortunately sounds as if we must develop our own central authentication system that is not built in Asp.NET Core, but instead a traditional Asp.NET app that authenticates users and in turn, informs the Blazor server apps we create of the validated user instead.</p>