2013-12-11 36 views
0

当我的站点处于空闲状态时,我想在asp.net中自动注销我的站点。 我使用身份验证在web.config中将sessiontimeout设置为“10分钟”。 例如:如果我的网站处于闲置状态9分钟,然后我使用mysite(即,使我的网站非活动模式为活动模式)。然后,计时器将不得不从新会话开始(例如它必须以0:0:0开始)。 如果我的会话超时(即超过10分钟)网站将不得不自动注销.. 请指导我?? 任何想法????如何在asp.net中10分钟后自动注销我的网站,在我的网站处于闲置状态?

回答

0

您可以使用表单身份验证并为您的目的设置会话超时。

<configuration> 
    <system.web> 
    <sessionState timeout="10"></sessionState> 
    </system.web> 
</configuration> 

这将使会话时间超出10分钟。如果任何请求在10分钟之前到来,那么它将再次增加(总共10分钟)。

更多详细信息
How to set session timeout in web.config

您可以使用slidingExpiration="false"在你的web.config文件,如果你只婉10分钟。

More details

根据MSDN

When the SlidingExpiration is set to true, the time interval during which the authentication 
cookie is valid is reset to the expiration Timeout property value. This happens if the user 
browses after half of the timeout has expired. For example, if you set an expiration of 20 
minutes by using sliding expiration, a user can visit the site at 2:00 PM and receive a cookie 
that is set to expire at 2:20 PM. The expiration is only updated if the user visits the site 
after 2:10 PM. If the user visits the site at 2:09 PM, the cookie is not updated because half 
of the expiration time has not passed. If the user then waits 12 minutes, visiting the site at 
2:21 PM, the cookie will be expired. 
0

很难明白你正在尝试做的。为什么这个问题用“javascript”和“ajax”标记?

会话状态不一定涉及表单身份验证。我本可以从您的网站发布一个持久性Cookie,并且无论您的网站保持闲置状态的时间长短都没有关系,我仍然可以向您的网站发送经过身份验证的请求...因为我拥有持久性Cookie。更重要的是,您甚至可以重新启动网站或您的应用程序池...我仍然不会从您的网站注销。

如果你想闲置10分钟后注销用户您的网站和您使用窗体身份验证,然后提出你的使用者,并在10分钟后过期饼干,见下文

<forms 
    timeout="10"> 
</forms> 
例如WEB.CONFIG

如果你想“重置”过期值,然后使用在web.config中滑动过期这样

<forms  
    timeout="10" 
    slidingExpiration="true"> 
</forms> 

您可以指定窗体身份验证有更多的价值。阅读MSDN文档...

http://msdn.microsoft.com/en-us/library/1d3t3c61(v=vs.85).aspx

我觉得你是一个有点糊涂。希望这个答案让事情更清楚一点我对你的朋友

利奥

+0

我明白谢谢 – PremKumar