【发布时间】:2016-06-23 17:50:54
【问题描述】:
当用户第一次访问基于 Windows 身份验证的系统时,我使用会话 cookie 来存储一个 int。 cookie是使用这种方法设置的
public ActionResult SetContractId(int contractId)
{
Session["LoggedContractId"] = contractId;
return RedirectToAction("IndexLoggedIn");
}
并使用 this 在其他方法中访问它
var creatorContractId = (int)Session["LoggedContractId"];
但是这个 cookie 在 20 分钟后超时,我似乎无法控制这个时间
我已经在 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>
但不影响它
【问题讨论】:
-
将 mode="InProc" 属性添加到您的 sessionState 元素
标签: c# asp.net-mvc session cookies