title: Redirect to another page from _Layout.cshtml
body: <p>How to redirect to another page within the _layout.cshtm page in asp.net core razor.</p>
  
  <p>I am doing the verification and user is logged in, if not it will be redirected to another page.</p>
  
  <pre><code>@using Microsoft.AspNetCore.Identity
  @using CronoParque.Model
  @inject SignInManager&lt;ApplicationUser&gt; SignInManager
  @inject UserManager&lt;ApplicationUser&gt; UserManager
  
  @if (SignInManager.IsSignedIn(User))
  {
      &lt;form asp-controller="Account" asp-action="Logout" method="post" id="logoutForm" class="navbar-right"&gt;
          &lt;ul class="nav navbar-nav navbar-right"&gt;
              &lt;li&gt;
                  &lt;a asp-page="/Account/Manage/Index" title="Manage"&gt;Ola @UserManager.GetUserName(User)!&lt;/a&gt;
              &lt;/li&gt;
              &lt;li&gt;
                  &lt;button type="submit" class="btn btn-link navbar-btn navbar-link"&gt;Sair&lt;/button&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
      &lt;/form&gt;
  }
  else
  {
      // targeting here
  }
  </code></pre>