title: Session is being abandoned in asp.net web application
body: <p>I have an asp.net c# web application running on a server, My application keeps sending me to the login page even after 1 minute, My server provider say nothing is wrong on the server configurations, I have defined my web.config file as below:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;configuration&gt;
  &lt;connectionStrings&gt;
  &lt;add name="myConnectionString" connectionString="Data Source=123.123.123.123;User ID=myUserID;Password=myPassword;"/&gt;
  &lt;/connectionStrings&gt;
  &lt;system.web&gt;
  &lt;sessionState timeout="30"&gt;&lt;/sessionState&gt;
  &lt;compilation debug="true" targetFramework="4.5" defaultLanguage="c#"&gt;
      &lt;assemblies&gt;
        &lt;add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;
        &lt;add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/&gt;
        &lt;add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/&gt;
        &lt;add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/&gt;
      &lt;/assemblies&gt;
    &lt;/compilation&gt;
    &lt;httpRuntime targetFramework="4.5" /&gt;
    &lt;httpHandlers&gt;
      &lt;add verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/&gt;
    &lt;/httpHandlers&gt;
  &lt;machineKey
  validationKey="374A70A6EF0A2F8C1F821D125FCF6503DEA7E9CE467B433086B058D86FAB67338
  C3A37E580F29FF27E86D079CC9153E396ABF495821E84C7B7B1F42F4467F1CA"
   decryptionKey="C74E21EE5B3C592C62C1BC5E682ED3CC4BD389CCC3AEA317AE1772E0D6750141"
  validation="SHA1" decryption="AES"
  /&gt;
  &lt;/system.web&gt;
  &lt;system.webServer&gt;
   &lt;handlers&gt;
    &lt;add name="CaptchaImage" verb="GET" path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha"/&gt;
   &lt;/handlers&gt;
    &lt;validation validateIntegratedModeConfiguration="false"/&gt;
    &lt;httpErrors errorMode="Custom"&gt;
      &lt;remove statusCode="404"/&gt;
     &lt;error statusCode="404" path="~/pr/http404.aspx" responseMode="ExecuteURL"/&gt;
   &lt;/httpErrors&gt;
  &lt;/system.webServer&gt;  
  &lt;/configuration&gt;
  </code></pre>
  
  <p>And in my .aspx files I use the below code to check the session</p>
  
  <pre><code>protected void Page_Load(object sender, EventArgs e)
  {
      try
      {
          if (Session["user"] == null || userRole() != "Admin")
              Response.Redirect("../Default.aspx", false);
          else
          {
              // some code here..
          }
      }
      catch(Exception ex)
      {
          litAlert.Text = "&lt;div class='alert alert-danger' role='alert'&gt;&lt;div&gt;&lt;span&gt;&lt;strong&gt;An error has occured. Please try again&lt;/strong&gt;&lt;/span &gt;&lt;/div&gt;&lt;/div&gt;";
      }
  }
  </code></pre>
  
  <p>Any help would be much appreciated</p>