title: Check if user is logged on in ASP.NET Core
body: <p>I'm new to ASP.NET Core and I'm still very uncomfortable. Anyways, I would like to know if this way is correct or if exists better solutions.</p>
  
  <p>I'm checking on every page if a user is logged on. If not, I will redirect page to login page:</p>
  
  <pre><code>public IActionResult Index()
  {
      if (User.Identity.IsAuthenticated)
      {
          return View();
      }
      else
      {
          return Redirect("Identity/Account/Login");
      }
  }
  </code></pre>
  
  <p>I'm adding this in every single page.</p>