During this time, no one visited the website again. As a result, the scheduled execution of the program code in Application_Start was not executed again. I searched the internet and found a solution. Now I want to share with you the solution, the principle is to send a Web request at the end of the application to access the website and start Application_Start.
Copy codeThe Code is as follows:
Void Application_End (object sender, EventArgs e)
{
// Code that runs when the application is closed
// Solve the application pool recycle Problem
System. Threading. Thread. Sleep (5000 );
String strUrl = "website address ";
System. Net. HttpWebRequest _ HttpWebRequest = (System. Net. HttpWebRequest) System. Net. WebRequest. Create (strUrl );
System. Net. HttpWebResponse _ HttpWebResponse = (System. Net. HttpWebResponse) _ HttpWebRequest. GetResponse ();
System. IO. Stream _ Stream = _ HttpWebResponse. GetResponseStream (); // get the write-back byte Stream
}