ASP generates HTML static page

Source: Internet
Author: User
Tags add end variable

Principle: Transfer variables through the browser, such as

Http://127.0.0.1/shengcheng.asp?id=90

Code:
If SaveFile ("/new/" &id& ". html", "http://127.0.0.1/news.asp?id=" &id& "") Then

/new "&id&". html "is the file and path you generate." Http://127.0.0.1/news.asp?id= "&id&" is the ASP's path
You can set your own changes, where "&id&" is a variable to read the browser. Change the URL to your own.

Use the method to add a connection to your list of articles, such as http://127.0.0.1/shengcheng.asp?id=90

90 This variable I believe you will call it, so you can generate in the/new directory by ID of the HTML article

shengcheng.asp files are as follows:

 
 
  1. <%
  2. Dim ID
  3. id = Request ("id")
  4. %>
  5. <%
  6. If SaveFile ("/new/" &id& ". html", "http://127.0.0.1/news.asp?id=" &id& "") Then
  7. Response.Write "Generated"
  8. Else
  9. Response.Write "No Build"
  10. End If
  11. function SaveFile (Localfilename,remotefileurl)
  12. Dim Ads, retrieval, Getremotedata
  13. On Error Resume Next
  14. Set retrieval = Server.CreateObject ("Microso" & ft.) XM "&" Lhttp ") '//Take apart the word to prevent the killing of antivirus software
  15. With retrieval
  16. . Open "Get", Remotefileurl, False, "", ""
  17. . Send
  18. Getremotedata =. Responsebody
  19. End With
  20. Set retrieval = Nothing
  21. Set Ads = Server.CreateObject ("Ado" & "db.") Str "&" Eam ") '//Take apart the word to prevent the killing of antivirus software
  22. With Ads
  23. . Type = 1
  24. . Open
  25. . Write Getremotedata
  26. . SaveToFile Server.MapPath (LocalFilename), 2
  27. . Cancel ()
  28. . Close ()
  29. End With
  30. Set ads=nothing
  31. If Err <> 0 Then
  32. SaveFile = False
  33. Err.Clear
  34. Else
  35. SaveFile = True
  36. End If
  37. End Function
  38. %>

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 be given priority. 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.

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.