0

I use a session cookie to store an int when users first visit the system which is based on windows authentication. The cookie is set using this method

public ActionResult SetContractId(int contractId)
{
    Session["LoggedContractId"] = contractId;

    return RedirectToAction("IndexLoggedIn");
}

And access it in other methods using this

var creatorContractId = (int)Session["LoggedContractId"];

However this cookie times out after 20 mins and I cant seem to control this time

I have tried this in the webconfig

<system.web>
    <sessionState mode="InProc" timeout="1200" />
    <compilation debug="true" targetFramework="4.5.1" />
    <httpRuntime targetFramework="4.5.1" />
    <authentication mode="Windows" />
    <customErrors mode="Off" />
    <authorization>
        <deny users="?" />
    </authorization>
</system.web>

But it doesnt affect it

krlzlx
  • 5,752
  • 14
  • 47
  • 55
Phill Sanders
  • 487
  • 2
  • 10
  • 30

2 Answers2

1

It will not work until you don't exceed the application pool recycle time in IIS. This web.config setting takes effect if and only if it is less than or equal to Application Pool recycle settings. By default application pool has a setting of 20 minutes so please change that and then alter the web.config... it will 100% work.

SharpC
  • 6,974
  • 4
  • 45
  • 40
Varun Vasishtha
  • 461
  • 2
  • 9
  • I'm not familiar with IIS, where abouts is it in IIS8.5? – Phill Sanders Mar 09 '16 at 13:11
  • 1
    Go to an application pool in which your website is configured , on the click of application pool on the right side, you can find Advance Settings, click on it, then find Idle Time Out property and change it – Varun Vasishtha Mar 09 '16 at 13:14
0

Add mode also, this will work.

 <system.web>
       <compilation debug="false" targetFramework="4.5.1" />
        <sessionState mode="InProc" timeout="240" />
      </system.web>
Anil
  • 3,722
  • 2
  • 24
  • 49