MubashirQureshi
MubashirQureshi

Reputation: 27

Session Expire in MVC

I am facing a problem, I have set session time out in web.config

<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

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

Upvotes: 0

Views: 1116

Answers (1)

ta.speot.is
ta.speot.is

Reputation: 27214

You never actually ask a question, so I'll take a stab at guessing what you're asking...

<sessionState timeout="60" mode="InProc" />

When mode="InProc", setting timeout="60" usually does not extend the session timeout beyond 20 minutes because the application pool will spin down (by default) after 20 minutes.

No application pool = no process = no session.

Either change your application pool settings or use a different session state provider.

Upvotes: 1

Related Questions