title: Change layout in Blazor page based on URL
body: <p>We are exploring whether we can slowly migrate an old WinForms application to be a blazor web application.</p>
  <p>Until the entire application would be migrated, we will expose each forms functionality as a blazor page one at a time.  If the web application is missing (not yet implemented) functionality, the users can open the full WinFroms app to get what they need done.</p>
  <p>To make this work, I would like to have one page that has different layouts depending on what UI client is accessing the page.  So if you are accessing via the web, it should display the nav menu, header footer, etc...  If it's being accessed as an embedded WebControl2 view within the Winforms app (I don't want to duplicate code across the 2 platforms) then all the navbar/header/footer stuff should be gone because the Winforms app assumes that functionality.</p>
  <p>My initial idea was to do have 2 URLs that go to the same page and have the page apply a different layout depending on whether the web app was used (the navLinks would use the 'employees' url) or whether the Winforms app was accessing it (the winforms app would load the '/winforms/employees' url) like this:</p>
  <pre><code>@page &quot;/employees&quot;
  @page &quot;/winforms/employees&quot;
  
  
  @inject NavigationManager MyNavigationManager
  
  @if (MyNavigationManager.Uri.Contains(&quot;winforms&quot;))
  {
      @layout AppHostLayout
  }
  else
  {
      @layout MainLayout
  }
  </code></pre>
  <p>However this does not work because you can only have ONE layout directive per page.</p>
  <p>Is there a better and/or blazor-specific way to achieve my desired outcome?</p>