title: Application_End Logout Users in global.asax
body: <p>I want to ask that can i logout user in Application_End???
  ,I know when Application_End invokes <a href="https://stackoverflow.com/questions/288350/application-end-global-asax">Application_End global.asax</a></p>
  
  <p>But i just want to know that is it right to make all users logout in Application End, I just want to enter logout date time of user.</p>
  
  <pre><code>    void Application_End(object sender, EventArgs e)
      {
          try
          {
              var LisLoginUsers = db.USER_LOGIN.Where(z =&gt; z.LOGOUT_DATETIME == null).ToList();
              if (LisLoginUsers.Count != 0)
              {
                  for (int i = 0; i &lt; LisLoginUsers.Count; i++)
                  {
                      LisLoginUsers[i].LOGOUT_DATETIME = System.DateTime.Now;
                      db.SaveChanges();
  
                  }
              }
          }
          catch (Exception msg)
          {
              ExceptionLogging.SendErrorToText(msg);
              Response.Redirect("/Account/Error/");
  
          }
      }
  </code></pre>