Recently, I am working on a project and need to regularly execute some operations in the program. The results show that the Timer Program is not often executed from every day to the next day, later, I realized that the application was stopped because of the application pool Recycle of IIS, And no one visited the website again during this time. As a result, the program code in application_start was not executed at a scheduled time, I searched for a solution on the Internet and shared it with you. The principle is to send a Web request at the end of the application to access the website and start application_start.
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}