我的网站上有两个页面.用户只能看到第一页.用户无权访问第二页.从不加载第二页. 但是我在第二页上有一个名为Add()的方法,该方法位于一个名为myfolder的文件夹中.如何每五分钟实施一次此方法. 我使用了以下代码,但是有问题. 在页面加载状态下执行该方法.如果关闭此页面,请勿一次调用此方法.在运行ASP.NET时,我并没有停止在ASP.NET中,只是关闭了浏览器屏幕. 我想要的是,即使用户没有打开页面,该方法也将在白天自动应用
There are two pages on my website. Only the first page the user sees. User does not have access to the second page.The second page is never loaded. But i have on the second page method called Add(), this method is in a folder called myfolder. How do I implement this method every five minutes. I''ve used the following code but there is a problem. Method is executed when the page is loaded condition. If you close this page, do not call this method at a time. While ASP.NET is running on, I did not stop in ASP.NET, I just close the browser screen. What I want is that the method will automatically be applied during the day, even when the user does not open the page
<asp:Timer ID="Timer1" OnTick="Timer1_Tick" runat="server" Interval="300000" /> <asp:UpdatePanel ID="UpdatePanell" runat="server" UpdateMode="Always"> <Triggers> <asp:AsyncPostBackTrigger ControlID="Timer1" EventName="Tick" /> </Triggers>
protected void Timer1_Tick(object sender, EventArgs e) { myclass a=new myclass; a.Add(); }
推荐答案
参考: stackoverflow/questions/4409558/c-sharp-timer-每5分钟运行一次 [ ^ ] Refer: stackoverflow/questions/4409558/c-sharp-timer-run-every-5th-minute[^]
更多推荐
每五分钟执行一次方法
发布评论