Click here to Skip to main content
15,887,683 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am facing the log out issue in my MVC5 application.

if I am opening tab 1, finish our work and leave it open, then open tab two and continue working in tab two for 15 minutes, tab one will return to the log in page due to automatically logout(Timeout set in 15 minutes in web.config).

below are the web.config configuration


JavaScript
<system.web>
    <httpCookies httpOnlyCookies="true" />
    <customErrors mode="On">
      <error statusCode="500" redirect="~/Error/InternalServer" />
      <error statusCode="404" redirect="~/Error/Index" />
      <error statusCode="403" redirect="~/Error/BadRequest" />
      <error statusCode="401" redirect="~/Unauthorised/Index" />
    
    <caching>
      <outputCache enableOutputCache="false" enableFragmentCache="false" />
    
    <!--<customErrors mode="On" defaultRedirect="Error" redirectMode="ResponseRedirect" />-->
    <authentication mode="Forms">
      <forms loginUrl="~/Account/LogOff" protection="All" timeout="1" slidingExpiration="true" cookieless="UseCookies" requireSSL="true" />
    
    <compilation debug="true" targetFramework="4.5.1">
      <assemblies>
        <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc, Version=5.1.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
      
    
    <!--<httpRuntime targetFramework="4.5"  />-->
    <httpRuntime executionTimeout="99999" maxRequestLength="162529280" maxUrlLength="400" minFreeThreads="6" useFullyQualifiedRedirectUrl="false" />
    <pages>
      <namespaces>
        <add namespace="Kendo.Mvc.UI" />
      
    
    <httpmodules>
      <add name="ErrorLog" type="Elmah.ErrorLogModule, Elmah" />
      <add name="ErrorMail" type="Elmah.ErrorMailModule, Elmah" />
      <add name="ErrorFilter" type="Elmah.ErrorFilterModule, Elmah" />
    
    <globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" culture="en-US" uiCulture="en-US" />
  

What I have tried:

I don't know the reason why it is happening
Posted
Updated 11-Jan-18 17:15pm
Comments
[no name] 9-Jan-18 6:37am    
That is the expected behavior
piushshukla 9-Jan-18 7:03am    
I don't want to log out even I am working on the second tab.
Richard Deeming 9-Jan-18 11:08am    
You've set the timeout on the authentication cookie to 1 minute, which seems a little short.

You've also set the log-in URL to "~/Account/LogOff", which is probably not what you intended.

If you want to keep the session and authentication cookies alive whilst a page is open, you'll need to use Javascript to send a regular background request to the server.
Karthik_Mahalingam 9-Jan-18 12:04pm    
use  Reply   button to post comments/query to the concerned user, so that the user gets notified and respond to your text.

1 solution

use this:


<configuration>
  <system.web>
     <sessionState timeout="20"></sessionState>
  </system.web>
</configuration>



where Timeout refers to the time .. You can even use Cookie Authentication for this
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900