title: How to auto redirect to login page when session expires on a site with master page
body: <p>I am working on an asp.net webforms project with master page. I would like the website auto redirect to the login.aspx page when the session ends. I tried the suggestion given at the following link.
  <a href="https://code.msdn.microsoft.com/Auto-redirect-to-login-e1782b2f" rel="nofollow noreferrer">https://code.msdn.microsoft.com/Auto-redirect-to-login-e1782b2f</a>
  Essentially I have copied the javascript from the link to the master page's aspx head section and used the C# code in the master page's page load event. But it doesn't redirect to the login page after the set 3 min session timeout. I have the following entry in my web.config file.</p>
  
  <pre><code>&lt;sessionState mode="InProc" stateConnectionString="tcpip=127.0.0.1:42424" 
  sqlConnectionString="data source=127.0.0.1;Trusted_Connection=yes" 
  cookieless="false" timeout="3" /&gt;
  </code></pre>
  
  <p>I even tried through the global.ascx page as suggested by this link, which didn't work either.
  <a href="http://www.c-sharpcorner.com/UploadFile/0c1bb2/redirect-page-after-session-time-out-in-Asp-Net424/" rel="nofollow noreferrer">http://www.c-sharpcorner.com/UploadFile/0c1bb2/redirect-page-after-session-time-out-in-Asp-Net424/</a>
  Thanks</p>