title: How To Set Logon Expiry in ASP.NET Core Identity
body: <p>Reference:<br>
  <a href="https://docs.asp.net/en/latest/tutorials/first-web-api.html" rel="nofollow">Building Your First Web API with ASP.NET Core MVC and Visual Studio</a></p>
  
  <p>Scenario:<br>
  (a) a .NET Core 1.0 Web API solution was built using the above link.<br>
  (b) That solution was run in Debug mode.<br>
  (c) a user registered<br>
  (d) that user logged on<br>
  (e) many hours later that user is still logged on</p>
  
  <p>Still in the same Debug session, this code gets executed:   </p>
  
  <pre><code>@using Microsoft.AspNetCore.Identity
  
  @inject SignInManager&lt;ApplicationUser&gt; SignInManager
  @inject UserManager&lt;ApplicationUser&gt; UserManager
  
  @if (SignInManager.IsSignedIn(User))
  {
      &lt;form asp-area="" asp-controller="Account" asp-action="LogOff" method="post" id="logoutForm" class="navbar-right"&gt;
          &lt;ul class="nav navbar-nav navbar-right"&gt;
              &lt;li&gt;
                  &lt;a asp-area="" asp-controller="Manage" asp-action="Index" title="Manage"&gt;Hello @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;Log off&lt;/button&gt;
              &lt;/li&gt;
          &lt;/ul&gt;
      &lt;/form&gt;
  }
  </code></pre>
  
  <p>My unfulfilled <em>expectation</em> was that the above mentioned user's logon would have timed out; however, <code>Hello *example user*!</code> and <code>Log off</code> are again rendered to the <strong>navbar</strong>; clicking <code>Log off</code> does log off the <em>example user</em>.</p>
  
  <p>So how does one set an expiry time in ASP.NET Core Identity so that<br>
  (a) a logged on user can be logged off after a fixed time period like 8 hours,<br>
  (b) a logged on user can be logged off after a fixed period of inactivity like 30 minutes? </p>