Global里定時任務自動停不會啟動,解決IIS應用程序池自動回收的問題


        protected void Application_End(object sender, EventArgs e)
        {

            SqlHelperSQLHIS.ExecuteNonQuery(" INSERT INTO a_test (cont) VALUES ('程序回收了') ", CommandType.Text);

            //下面的代碼是關鍵,可解決IIS應用程序池自動回收的問題  
            Thread.Sleep(1000);

            //這里設置你的web地址,可以隨便指向你的任意一個aspx頁面甚至不存在的頁面,目的是要激發Application_Start  
            string url = "http://m.91zn.cn:81/AmebaScore/Test01.aspx";
            HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(url);
            HttpWebResponse myHttpWebResponse = (HttpWebResponse)myHttpWebRequest.GetResponse();
            Stream receiveStream = myHttpWebResponse.GetResponseStream();//得到回寫的字節流  
            SqlHelperSQLHIS.ExecuteNonQuery(" INSERT INTO a_test (cont) VALUES ('程序自動重新啟動了') ", CommandType.Text);
        }

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM