关于global.asax的问题,高人们请进来指点一下谢谢了!
我在global.asax中的application_start事件中写了个每隔一段时间自动运行一段程序的代码片段本地测试完全没问题,但是发布到远程服务器上以后就不执行了,各位有类似的经验吗?给在下出出主意谢谢了!在线等。
PS:我是穷人,只能给的起20分,还请大家不要嫌少~ --------------------编程问答-------------------- 关注 --------------------编程问答-------------------- 代码呢…… --------------------编程问答-------------------- 好的 我贴出代码片段请大家帮我看看 --------------------编程问答-------------------- void Application_Start(object sender, EventArgs e)
{
System.Timers.Timer myTimer = new System.Timers.Timer(180000);
myTimer.Elapsed += new System.Timers.ElapsedEventHandler(myTimer_Elapsed);
myTimer.Enabled = true;
myTimer.AutoReset = true;
}
void myTimer_Elapsed(object source, System.Timers.ElapsedEventArgs e)
{
try
{
Log.SaveNote(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ":AutoTask is Working!");
MyTask();
}
catch (Exception ee)
{
Log.SaveException(ee);
}
}
void MyTask()
{
GetMainData gmd = new GetMainData();
//string path = System.AppDomain.CurrentDomain.BaseDirectory.ToString();
StreamReader sreader = new StreamReader(System.AppDomain.CurrentDomain.BaseDirectory.ToString() + "Index.htm", Encoding.UTF8);
string html = sreader.ReadToEnd();
html = html.Replace("$News", gmd.GetNews());
html = html.Replace("$marquePic1", gmd.GetNewArrive());
html = html.Replace("$marquePic2", gmd.GetNewArrive());
html = html.Replace("$malecloth", gmd.GetMaleHot());
html = html.Replace("$femalecolth", gmd.GetFemaleHot());
html = html.Replace("$marqueBrand1", gmd.GetBrand());
html = html.Replace("$marqueBrand2", gmd.GetBrand());
//html = html.Remove("$goodscount", gmd.GetGoodsCount());
StreamWriter sw = new StreamWriter(System.AppDomain.CurrentDomain.BaseDirectory.ToString() + "Main.htm", false, Encoding.UTF8);
sw.Write(html);
sw.Close();
} --------------------编程问答-------------------- 这个是为了提高首页访问速度用的,
就是每隔3分钟读取一个页面的模板 替换掉特定部分后生成一张静态页面 --------------------编程问答--------------------
关注!!
补充:.NET技术 , ASP.NET