Global.asax: <%@ Application Language="C#" Inherits="路径.Global" CodeBehind="Global.cs"%> Global.cs: public class Global : System.Web.HttpApplication { public static Timer gtimer = null; // 定义全局定时器类对象 protected void Application_Start(object sender, EventArgs e) { gtimer = new Timer(1000000); //16.7分钟执行一次方法 // 将自定义用户函数(TimerEventFunction)指定为计时器的 Elapsed 事件处理程序 // TimerEventFunction 可以写入自己的需要执行的代码逻辑 gtimer.Elapsed += new System.Timers.ElapsedEventHandler(this.TimerEventFunction); // AutoReset 属性为 true 时,每隔指定时间间隔触发一次事件 // 若赋值 false,则只执行一次 gtimer.AutoReset = true; gtimer.Enabled = true; } protected void TimerEventFunction(Object sender, ElapsedEventArgs e) { //触发事件,相应的操作! } }