title: aspnet identity user is signed out automatically after few seconds/minutes
body: <p>if you start a mvc5 project from VS2013 applying aspnet identity. you will find in the _LoginPartiaView.cshtml the following code:</p>
  
  <pre><code>@if (Request.IsAuthenticated )
  {
      using (Html.BeginForm("LogOff", "Account", FormMethod.Post, new { id = "logoutForm", @class = "navbar-right" }))
      {
      @Html.AntiForgeryToken()
                  @Html.ActionLink( "Hello " + User.Identity.GetUserName() , "profile", "Account", routeValues: null, htmlAttributes: new { title = "Manage" })
          &lt;a href="javascript:document.getElementById('logoutForm').submit()"&gt;Log off&lt;/a&gt;
  
      }
  }
  </code></pre>
  
  <p>which means that with every request the user is being checked wether authenticated or not. That would be beautiful if it can be.</p>
  
  <p>however my problem is that testing on the development machine, it works fine. But when tested on remote server [shared hosting] then the user is logged out after  being idle for a few seconds-minutes.</p>
  
  <p>Then I searched to find this <a href="https://stackoverflow.com/questions/12352931/response-isauthenticated-is-false-after-30-seconds">SO - isAuthenticated result is false</a> and the accepted answer said:</p>
  
  <blockquote>
    <p>the host is killing the AppPool in the server when it is a few seconds
    idle.</p>
  </blockquote>
  
  <p>and some comment says: </p>
  
  <blockquote>
    <p>do note that the AppPool will still be recycled every now and then, so
    a small % of users are likely still getting that.</p>
  </blockquote>
  
  <p>So I was thinking that session [mode : SqlServer] can be the solution; and code will check <code>session["userName"]</code> instead of <code>@if (Request.IsAuthenticated )</code></p>
  
  <p>the question is:
  is using the session for storing user name and authenticating actions acceptable?
  is there any other better concept that is applicable here ?</p>
  
  <p><strong>Edit</strong>:
  Answering Brad Q; here is the relevant web.config set up:</p>
  
  <pre><code> &lt;authentication mode="Forms" &gt;
        &lt;forms loginUrl="/Account/Login"
                timeout="180"/&gt;
      &lt;/authentication&gt;
  
      &lt;compilation debug="false" targetFramework="4.5" /&gt;
      &lt;httpRuntime targetFramework="4.5" /&gt;
  
  
      &lt;sessionState mode="SQLServer" 
                    timeout="60"
                    allowCustomSqlDatabase="true"
                    sqlConnectionString="Data Source=xxxx.net;Initial Catalog=luckysessions;User ID=xxadmin;Password=xxxx;" 
                    cookieless="false"/&gt;
  </code></pre>
  
  <p><strong>2nd Edit:</strong></p>
  
  <p>after reading this SO question <a href="https://stackoverflow.com/questions/9730385/logged-in-users-get-logged-out-after-some-time?rq=1">here</a> I started to think again and wanted to add this question:
  Is it related to web-farm server setup?</p>