生成靜態網頁

2022-02-24 07:44:15 字數 1999 閱讀 3813

方式1(模版):

在模版中編輯一些符號,然後從資料庫中提取資料替換這些符號並按照時間(年-月-日)或其他的規則生成到硬碟中.這種方式過於簡單在此不在累述.

方式2(httpwebrequest):

1///

2///

write the html file.

3///

4///

the page url.

5///

the encode type str.

6///

the local disk path.

7///

8///

9///

10///

11         

///writerhtmlfile("/tdd2005/rpt_todayfocus.aspx", "utf-8", "/tdd2005/rpt_todayfocus.htm")

12///

]]>

13///

14///

15///

is success

16public

static

bool

writehtmlfile(

string

pageurl, 

string

encodetypestr, 

string

localdiskpath)

1736

catch

(exception ex)

3741

} 方式3(rander方式):

1///

2///

initializes the 

object and calls on the child controls of the 

to render.

3///

4///

5///

the 

that receives the page content.

6protected

override

void

render(htmltextwriter writer)

7.ascx

", _city_id);9if

1013

system.io.stringwriter html 

=new

system.io.stringwriter();

14system.web.ui.htmltextwriter tw 

=new

system.web.ui.htmltextwriter(html);

15base

.render(tw);

16system.io.streamwriter sw;

17sw 

=new

false

, system.text.encoding.default);

18sw.write(html.tostring());

19sw.close();

20tw.close();

21//

response.write(html.tostring());  

//呈現頁面

22//

response.redirect(filename);      

//重定向生成的頁面

23response.redirect

在啟動頁面page_load

1///

2///

loads the static page.

3///

author:petter liu  

4///

5private

void

loadstaticpage()

6.ascx", 

this

.city_id);8if

914else

1518

配置實現 靜態網頁生成

靜態網頁生成普遍的思路是利用寫好的aspx頁面,後台呼叫生成html。由於使用者一般不能編輯aspx頁面,但是對html一般可以編輯和處理。aspx生成html的原理其實就是將特定的標籤轉換為html,自己利用了這一原理自定義了自己的替換標籤,配合xml配置訪問資料實現了html模板生成靜態網頁。應...

配置實現 靜態網頁生成

靜態網頁生成普遍的思路是利用寫好的aspx頁面,後台呼叫生成html。由於使用者一般不能編輯aspx頁面,但是對html一般可以編輯和處理。aspx生成html的原理其實就是將特定的標籤轉換為html,自己利用了這一原理自定義了自己的替換標籤,配合xml配置訪問資料實現了html模板生成靜態網頁。應...

配置實現 靜態網頁生成

靜態網頁生成普遍的思路是利用寫好的aspx頁面,後台呼叫生成html。由於使用者一般不能編輯aspx頁面,但是對html一般可以編輯和處理。aspx生成html的原理其實就是將特定的標籤轉換為html,自己利用了這一原理自定義了自己的替換標籤,配合xml配置訪問資料實現了html模板生成靜態網頁。應...