日期:2014-05-17 浏览次数:20565 次
void Application_Start(object sender, EventArgs e)
{
//在应用程序启动时运行的代码
WebSiteRootPath = Server.MapPath("~");
System.IO.File.AppendAllText(WebSiteRootPath + "\\log.txt", "Application_Start 开始:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + Environment.NewLine);
System.Timers.Timer myTimer = new System.Timers.Timer(60000);
myTimer.Elapsed += new System.Timers.ElapsedEventHandler(doJob);
myTimer.Enabled = true;
myTimer.AutoReset = true;
}
void Application_End(object sender, EventArgs e)
{
//在应用程序关闭时运行的代码
}
void Application_Error(object sender, EventArgs e)
{
//在出现未处理的错误时运行的代码
}
void Session_Start(object sender, EventArgs e)
{
//在新会话启动时运行的代码
}
void Session_End(object sender, EventArgs e)
{
//用来监测程序池回收
System.IO.File.AppendAllText(WebSiteRootPath + "\\log.txt", "Application_Ent 会话结束:" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + Environment.NewLine);
//在会话结束时运行的代码。
// 注意: 只有在 Web.config 文件中的 sessionstate 模式设置为
// InProc 时,才会引发 Session_End 事件。如果会话模式
//设置为 StateServer 或 SQLServer,则不会引发该事件。
System.Threading.Thread.Sleep(1000);
//这里设置你的web地址,可以随便指向你的任意一个aspx页面甚至不存在的页面,目的是要激发Application_Start
//使用您自己的URL
string url = "http://www.云阳面坊.com/";
System.Net.HttpWebRequest myHttpWebRequest = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(url);
System.Net.HttpWebResponse myHttpWebResponse = (System.Net.HttpWebResponse)myHttpWebRequest.GetResponse();
System.IO.Stream receiveStream = myHttpWebResponse.GetResponseStream();
}
http://go.microsoft.com/fwlink/?LinkId=169433
-->
<configuration>
<system.web>
<compilation debug="true" targetFramework="4.0"/>
<sessionState mode="InProc" />
</system.web>
</configuration>