How to generate static Web pages by ASP

Source: Internet
Author: User
static | web | Static with the increase in the number of visits to the Web site, each read from the database is the cost of efficiency, many use Access as a database will be more experience, static page add in search, will also be preferred. The popular practice on the internet is to write the data source code into the database and then read from the database to generate static surface, so that the invisible room to enlarge the database. Creating a static page directly from an existing ASP page will save you a lot of money.

The following example is the three dynamic pages that will, index.asp?id=1/index.asp?id=2/index.asp?id=3/, respectively, generate the ndex1.htm,index2.htm,index3.htm existence root directory below:
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
%>



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.