IIS application pool reclamation solution to the problem of timing execution program stop in Application_Start
- 2020-05-09 18:23:20
- OfStack
However, no one visited the website again during this period. As a result, the program code in Application_Start was not executed at a fixed time. After searching on the Internet for 1 time, I found a solution.
void Application_End(object sender, EventArgs e)
{
// Code that runs when the application is closed
// Solve the application pool recycling problem
System.Threading.Thread.Sleep(5000);
string strUrl = " Web site 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();// Gets a stream of bytes to write back
}