推薦:在ASP.NET 2.0中使用樣式、主題和皮膚ASP.net2.0的主題和皮膚特性使你能夠把樣式和布局信息存放到一組獨立的文件中,總稱為主題(Theme)。接下來我們可以把這個主題應用到任何站點,用于改變該站點內的頁面和控件的外觀和感覺。通
前段時間有個asp頁面執行起來很慢,訪問人數又頗多,而且又不經常修改,又懶得直接做成靜態的,每次都要從服務器下載來改,只好想辦法把asp頁面轉化成htm靜態頁面了。
以前就曾經看到這樣的文章,不過沒太在意,真正想用的時候很難找到一個合適的,于是在網上搜索了半天終于找到比較合適的代碼再加上自己的修改,如下:
以下為引用的內容:
<% Function GetPage(url) '獲得文件內容 dim Retrieval Set Retrieval = CreateObject("Microsoft.XMLHTTP") With Retrieval .Open "Get", url, False ', "", "" .Send GetPage = BytesToBstr(.ResponseBody) End With Set Retrieval = Nothing End Function
Function BytesToBstr(body) dim objstream set objstream = Server.CreateObject("adodb.stream") objstream.Type = 1 objstream.Mode =3 objstream.Open objstream.Write body objstream.Position = 0 objstream.Type = 2 objstream.Charset = "GB2312" BytesToBstr = objstream.ReadText objstream.Close set objstream = nothing End Function
on error resume next Url="http://www.wf0088.com"'要讀取的頁面地址 response.write "開始更新首頁..." wstr = GetPage(Url)
'response.write(wstr) Set fs=Server.CreateObject("Scripting.FileSystemObject")
'if not MyFile.FolderExists(server.MapPath("/html/")) then 'MyFile.CreateFolder(server.MapPath("/html/"))' 'end if
'要存放的頁面地址 dizhi=server.MapPath("index.htm") If (fs.FileExists(dizhi)) Then fs.DeleteFile(dizhi) End If
Set CrFi=fs.CreateTextFile(dizhi) Crfi.Writeline(wstr) set CrFi=nothing set fs=nothing response.write "...<font color=red>更新完成!</font>" %>
|
代碼算是最簡單的,直接保存成一個asp文件即可,只要把URL(要轉化的asp地址)和dizhi(要保存的html地址)設置好就可以了,一般這兩個文件在同一個目錄,才能保證圖片或者css、js起作用。
希望對那些正在尋找由asp生成htm的朋友有用。
分享:cookie和session機制之間的區別與聯系具體來說cookie機制采用的是在客戶端保持狀態的方案。它是在用戶端的會話狀態的存貯機制,他需要用戶打開客戶端的cookie支持。cookie的作用就是為了解決HTTP協議無狀態的缺陷所作的努力。
而s