“表单超时”、“会员资格 userIsOnlineTimeWindow” 之间有什么区别?和“sessionState超时”
这些代码行有什么区别:
<forms timeout="5" />
<membership userIsOnlineTimeWindow="5" />
<sessionState timeout="5" />
非常感谢。
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
表单 (FormsAuthention) 用于身份验证当超时时,它将注销用户。您可以通过将 SlidingExpiration 属性设置为“true”来“防止”超时,并且如果需要,它将更新用户活动的表单票证(读取对 asp 的请求)。这将使用户在您的网站上处于“活动”状态时保持登录状态。
会员身份是用于用户验证,userIsOnlineTimeWindow 可帮助您跟踪用户活动,因此当它用完时,它将将该用户的 IsOnline 属性设置为“false”。我发现的一件新事情是,当设置用户 isOnline 时,它也会更新表单票证,主要区别在于它不会更新自己 > 自动但仅当其 GetUser() 或 ValidateUser() 方法运行时。
当会话超时时,您将丢失在Session 对象。仅此而已。
Forms (FormsAuthention) are used for authentication and when it times out it will logout user. You can 'prevent' timeout by setting SlidingExpiration property to 'true' and it will renew forms ticket on user activity (read request to asp) if needed. This will keep user logged on while he is 'active' on your site.
Membership is used for user validation and userIsOnlineTimeWindow is there to help you track user activity so when it runs out it will set IsOnline property to 'false' for that user. One new thing I found out is that it will also renew forms ticket while users isOnline is set, main difference is that it doesn't renew itself automatically but only when its GetUser() or ValidateUser() methods are run.
When session times out you will lose data found in Session object. That is all.
请注意以下行为:
您设置会话超时 = 10 分钟,表单身份验证超时 = 8 分钟。
用户使用表单身份验证登录到您的站点。
会话“时钟”和表单身份验证“时钟”都开始运行。
假设您在 Session 中保留了网站操作所需的一些信息(例如 Session["userData"] = userData;)。
用户闲置时间为 9 分钟。
8 分钟后,会话超时,用户数据被清除。
在第 9 分钟,当用户尝试在网站上执行某些活动时,您天真地引用 Session["userData"] 来获取他的信息。由于它为空,他将因空引用而收到错误 500。
结论:使表单身份验证超时时间短于会话超时时间。
Note the following behavior:
You set Session timeout = 10 minutes and Forms Authentication timeout = 8 minutes.
The user logs into your site using Forms Authentication.
Both the Session "clock" and Forms Authentication "clock" start running.
Suppose that you keep some info needed for the site's operation in the Session(For example, Session["userData"] = userData;).
The user is idle for 9 minutes.
At 8 minutes the session times out and the user's data is cleared.
At 9 minutes when the user tries to perform some activity on the site, you naively reference the Session["userData"] to get his info. Since it is null he will get error 500 for a null reference.
Conclusion: Keep the forms authentication timeout shorter than the session timeout.