简体   繁体   English

如果我使用计时器,Web应用程序会超时吗?

[英]Will a web app timeout if I'm using a timer?

So I have a timer that makes an async post back every 15 minutes. 因此,我有一个计时器,每15分钟发出一次异步回发。 I have the webconfig set up to timeout after 60 minutes. 我将webconfig设置为60分钟后超时。 But will it still time out? 但是它还会超时吗? From what I can tell it won't, is there a way to make it still time out? 据我所知,有没有办法使它仍然超时?

Forcing an asynchronous call will keep your asp.net session alive as long as the page with the timer is left open. 只要带有计时器的页面保持打开状态,强制进行异步调用将使您的asp.net会话保持活动状态。

However, you need to think if this is what you want the desired behaviour to be. 但是,您需要考虑这是否是您想要的期望行为。 For example, if your user has had to login to their session do you want the session to stay alive, if for example, they have walked away from their computer for their lunch break? 例如,如果您的用户必须登录到他们的会话,您是否希望该会话保持活动状态,例如,他们已经在午餐时间离开计算机了?

You also don't need to set your web.config to 60 minutes. 您也不需要将web.config设置为60分钟。 If using this technique every 15 minutes the standard 20 minutes timeout will be more than adequate. 如果每15分钟使用一次此技术,则20分钟的标准超时时间将绰绰有余。

An alternative solution would be to pop up a message to the user asking if they wish to stay logged in. If they respond yes, do the postback. 一种替代解决方案是向用户弹出一条消息,询问他们是否希望保持登录状态。如果他们回答“是”,则执行回发。

To get it to still timeout, stop the automatic postback after the 3rd go (15*3=45 + 20m standard = 65 minutes) 要使其保持超时,请在第三次执行后停止自动回发(15 * 3 = 45 + 20m标准= 65分钟)

If you have set the timeout value to a longer time it won't expire. 如果您将超时值设置为更长的时间,它将不会过期。 If you still want to invalidate the session you can programatically call the Abandon() method (for example after the fourth postback call). 如果仍然要使会话无效,则可以以编程方式调用Abandon()方法(例如,在第四次回发调用之后)。

Making an async postback will keep the session alive so I don't see it timing out at all. 进行异步回发将使会话保持活动状态,因此我完全看不到超时。 Instead of doing an async postback every 15 mins do it once in 55 mins where you show the user the count down informing them that their session is going to timeout. 而不是每15分钟执行一次异步回发,而是每55分钟执行一次,您可以在此向用户显示倒计时,以告知用户其会话即将超时。 If they want to reset it then let them click on a button in that window and then you can do an async postback. 如果他们想重置它,请让他们单击该窗口中的按钮,然后您可以进行异步回发。

HTH HTH

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

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