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}