How does ASP. NET regularly generate static pages?

Source: Internet
Author: User
How does ASP. NET regularly generate static pages?
Previously, it was generated by clicking the button manually. 1/*** /// <summary>
2 // generate a static page
3 /// </summary>
4 // <param name = "URL"> declare the variable for saving the URL </param>
5 // <param name = "NewURL"> location of the new page (including the generated file name) </param>
6 private void Build (string URL, string NewURL)
7 {
8 string errorMsg; // 'declares the variable for saving the error message
9
10 // URL = "http://www.xxx.cn/default.aspx"; // 'URL to be saved
11 errorMsg = "";
12 try
13 {
14 System. Net. WebRequest wReq;
15 System. Net. WebResponse wResp;
16 wReq = System. Net. WebRequest. Create (URL); // Create a request instance
17 wResp = wReq. GetResponse (); // Get Response
18 System. IO. streamReader reader = new System. IO. streamReader (wResp. getResponseStream (), System. text. encoding. default); // 'create a StreamReader instance and set the source character encoding to the Default
19 System. IO. streamWriter writer = new System. IO. streamWriter (NewURL, false, System. text. encoding. getEncoding ("gb2312"); // create a StreamWriter instance and set the target character encoding to gb2312.
20 // Response. Write (reader. ReadToEnd)
21 writer. Write (reader. ReadToEnd (); // 'write the file
22 writer. Flush (); // 'write the cached content to the file
23 writer. Close (); // 'release the instance
24 reader. Close (); // 'release the instance
25}
26 catch (Exception ex)
27 {
28 errorMsg = ex. ToString ();
29}
30}

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.