title: Middleware for Authencation
body: <p>I have created a ASP.NET MVC core application. I just finished creating and logging in a user. Now I'm trying to figure out <br>
  <strong>1.</strong> how to have the user login info saved  <br>
  <strong>2.</strong> how to require a user to be logged in to visit the rest of the the site.<br>
  For saving the user log info. I was going to use either <strong>Identity</strong> or <strong>Asp.Net.Session</strong>, but seeing has I cant find anything that shows how to require the user to be logged in to visit routes, I’m unsure which option would work best. <br>
  Could someone explain to me how to require authentication before accessing a route, and which of the saving login info works best with that method? </p>
  
  <p>Current Login Example</p>
  
  <pre><code>    public ActionResult Login(LoginModel model){
          if (ModelState.IsValid){
              SqlConnect test = new SqlConnect("Data Source=/home/andrew/database.db","Accounts"); 
              var check = test.count(model.UserName,model.Password); 
              if(check){
                  // Found in database 
                  return RedirectToAction("Index","Home");
              }
          }
  
          // If we got this far, something failed, redisplay form
          return RedirectToAction("Error","Home");
      }
  </code></pre>