Solve the problem that IIS application pool recycle causes timed execution program stop in application_start.

Source: Internet
Author: User

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}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.