生成靜態頁

2022-03-24 19:41:23 字數 1684 閱讀 2711

先定義乙個staticfilecachemodule

實現ihttpmodule介面

定製beginrequest事件

}再定義乙個類

要生成靜態頁面的繼承它就行了

將頁面內容輸出到瀏覽器

response.write(pagecontent);}}

當然不要忘在配置web.confing

用模板生成靜態頁

模板檔案: text.htm

[title]

[tan]

[conten]

**:private

void getwriter (string title,string tag,string content)

catch(exception exp)

string htmlfilename=title+".html";

// 替換內容

// 這時,模板檔案已經讀入到名稱為str的變數中了

str =str.replace("[title] ",title); //

模板頁中的title

str =str.replace("[tag] ",tag); //

模板頁中的tag

str =str.replace("[content] ",content); //

模板頁中的content

// 寫檔案

trycatch(exception ex)

finally

}以上**並非原著

再加乙個

public

void transhtml(string path, string outpath)

else

byte bt = encoding.default.getbytes(writer.tostring());

fs.write(bt, 0, bt.length);

fs.close();

}transhtml("default3.aspx", "default3.html");

將為default3.aspx生成乙個defult3.html的靜態頁面

php生成靜態頁

先建立一chtml資料庫 表名稱為bihtml create table bihtml id int 11 auto increment not null,szdtitle varchar 30 szdcontent text primary key id 在表中插入兩條記錄 insert into...

PHP生成靜態頁

最近作的乙個專案中用到了兩種用 php 生成靜態頁面的 方法 回想起當初自己還不知道如何生成靜態頁面的迷惘,以及看不懂高手寫的文章的痛苦,覺得自己有必要站出來為還不知道如何生成靜態頁的phper寫乙個通俗點文章,以幫助他們盡快掌握這個好東西。在我之前所見的文章中要不是用 堆砌空間就是用高手與高手交流...

如何生成靜態頁

方案1 傳入url返回網頁的html url public static string geturltohtml string url get the response stream.system.io.stream respstream wresp.getresponsestream dim re...