简体   繁体   English

在Visual Studio 2013 Express中测试会话超时

[英]Testing Session timeout in Visual Studio 2013 Express

I am using VS 2013 Express for Web. 我正在使用VS 2013 Express for Web。 I used to create a simple login exercise. 我曾经创建一个简单的登录练习。 When the user logs in, I create this form authentication in my login action method: 当用户登录时,我使用登录操作方法创建此表单身份验证:

FormsAuthentication.SetAuthCookie(model.Name, false);

and immediately place the name into a session: 并立即将名称放入会话中:

Session["name"] = model.name;

My session settings in the Web.config is as follows: 我在Web.config中的会话设置如下:

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

After the assignment of the session variable, if I pause execution at a break point, shouldn't the Session time out after 1 minute and becomes empty? 分配会话变量后,如果我在断点处暂停执行,则会话是否应在1分钟后超时并变为空? Currently, it continues having a value. 当前,它继续具有价值。

The value won't actually change whilst you're on a break-point, but you could set a break on the Session_End in the global.asax file to detect when the session times-out. 在断点时,该值实际上不会改变,但是您可以在global.asax文件中的Session_End上设置一个中断,以检测会话何时超时。 Take a look at working with Global.asax file to understand the different events. 看看使用Global.asax文件来了解不同的事件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM