ASP method for generating static web pages

Source: Internet
Author: User

Generating static pages from existing ASP pages will save a lot.
In the following example, www.111cn.net/index.asp? Id = 1/index. asp? Id = 2/index. asp? Id = 3/these three dynamic pages do not generate ndex1.htm,index2.htm,index3.htm exists in the root directory:
Code:
<%
Dim strUrl, Item_Classid, id, FileName, FilePath, Do_Url, Html_Temp
Html_Temp = "<UL>"
For I = 1 To 3
Html_Temp = Html_Temp & "<LI>"
Item_Classid = I
FileName = "Index" & Item_Classid & ". htm"
FilePath = Server. MapPath ("/") & "\" & FileName
Html_Temp = Html_Temp & FilePath & "</LI>"
Do_Url = "http ://"
Do_Url = Do_Url & Request. ServerVariables ("SERVER_NAME") & "/main/index. asp"
Do_Url = Do_Url &"? Item_Classid = "& Item_Classid
StrUrl = Do_Url
Dim objXmlHttp
Set objXmlHttp = Server. CreateObject ("Microsoft. XMLHTTP ")
ObjXmlHttp. open "GET", strUrl, false
ObjXmlHttp. send ()
Dim binFileData
BinFileData = objXmlHttp. responseBody
Dim objAdoStream
Set objAdoStream = Server. CreateObject ("ADODB. Stream ")
ObjAdoStream. Type = 1
ObjAdoStream. Open ()
ObjAdoStream. Write (binFileData)
ObjAdoStream. SaveToFile FilePath, 2
ObjAdoStream. Close ()
Next
Html_Temp = Html_Temp & "<UL>"
%>
<%
Response. Write ("successfully generated File :")
Response. Write ("<BR> ")
Response. Write Html_Temp
%>

At last, this method is stupid. You can customize the template to generate it again, which can reduce the burden on the server.

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.