How to solve the problem that IIS application pool recycle causes timed execution program stop in Application_Start

Source: Internet
Author: User

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
}

Related Article

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.