【问题标题】:Testing Session timeout in Visual Studio 2013 Express在 Visual Studio 2013 Express 中测试会话超时
【发布时间】:2015-06-11 12:58:05
【问题描述】:

我正在使用 VS 2013 Express for Web。我曾经创建一个简单的登录练习。当用户登录时,我在我的登录操作方法中创建此表单身份验证:

FormsAuthentication.SetAuthCookie(model.Name, false);

并立即将名称放入会话中:

Session["name"] = model.name;

我在 Web.config 中的会话设置如下:

<authentication mode="Forms">
  <forms loginUrl="~/Account/Login" timeout="10"/> 
</authentication>
<sessionState timeout="1" /> <!-- only one minute-->

在session变量赋值后,如果我在断点处暂停执行,难道Session不应该在1分钟后超时变空吗?目前,它仍然具有价值。

【问题讨论】:

  • 暂停时如何检查值?

标签: c# asp.net-mvc session visual-studio-2013 session-timeout


【解决方案1】:

当您处于断点时,该值实际上不会改变,但您可以在 global.asax 文件中的 Session_End 上设置一个中断,以检测会话何时超时。查看working with Global.asax 文件以了解不同的事件。

【讨论】:

    猜你喜欢
    • 2016-05-27
    • 2014-02-25
    • 2023-03-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-12-23
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多