简体   繁体   中英

Testing Session timeout in Visual Studio 2013 Express

I am using 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:

<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? 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. Take a look at working with Global.asax file to understand the different events.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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