Click here to Skip to main content
15,892,005 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have facing a problem,
I have set session time out in web.config

XML
<system.web>
      <sessionState timeout="60" mode="InProc" />
    <httpRuntime targetFramework="4.5" />
    <compilation debug="true" targetFramework="4.5" />
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="2880" />
    </authentication>
  </system.web>



In my controller

SQL
public ActionResult CreateBrand()
        {
            Session.Timeout=60;
            Purchase purchase = Session["purchaseItem"] as Purchase;
            if (purchase!=null && purchase.Brand != null)
            {
                return View(purchase.Brand);
            }
            return View();
        }



Any bode can tell me what is the problem with session. Why session expire very quickly, may be within just 1 i or 2 minutes?
Posted
Comments
Check IIS settings.

1 solution

Do you absolutely need to use InProc? I suggest you either use (a) Session State Server or (b) SQL Server to manage your user sessions. I have not had one client complain about their session expiring after leaving their computer for 10-20 minutes, and we are using SQL Server to manage the user sessions. SQL Server-based sessions also survives application pool recycles.

Alternatively, and if you absolutely MUST use InProc, then you can try two different things: (a) Ensure your application pools' timeout is set correctly, and (b) implement something like an IFRAME that refreshes the user session automatically every few seconds or minutes ("Keep Alive").

First, try the IIS method:
- Open IIS
- Select Application Pools on the left side
- Select the Application Pool used by your site
- Choose advanced settings
- Under Process Model categtory increase the 'Idle Time-out' value to the desired length.

Second, try searching Google for an ASP.NET Keep Alive example. Hope this info helps!
 
Share this answer
 

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