將aspx網頁以HTML形式儲存的幾個方法

2021-04-08 21:45:25 字數 1978 閱讀 4121

aspx網頁以html形式儲存的幾個方法

第一種是模版替換:

環境:microsoft .net framework sdk v1.1

os:windows server 2003 中文版

asp.net生成靜態html頁

在asp中實現的生成靜態頁用到的filesystemobject物件!

在.net中涉及此類操作的是system.io

以下是程式** 注:此**非原創!參考別人**

// 生成html頁

public

static

bool

writefile(

string

strtext,

string

strcontent,

string

strauthor)

catch

(exception exp)

string

htmlfilename

=

datetime.now.tostring(

"

yyyymmddhhmmss

"

)

+

"

.html

"

;

//

替換內容

//

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

str 

=

str.replace(

"

showarticle

"

,strtext); 

//

模板頁中的showarticle

str 

=

str.replace(

"

biaoti

"

,strtext);

str 

=

str.replace(

"

content

"

,strcontent);

str 

=

str.replace(

"

author

"

,strauthor);

//

寫檔案

try

catch

(exception ex)

finally

return

true

;

此函式放在conn.cs基類中了

在新增新聞的**中引用 注:工程名為hover

if(hover.conn.writefilethis.title.text.tostring),this.content.text.tostring),this.author.text.tostring)))

else

模板頁text.html**

showarticle

biaoti

content

author

biaoti

content

author

提示新增成功後會出以當前時間為檔名的html檔案!上面只是把傳遞過來的幾個引數直接寫入了html檔案中,

在實際應用中需要先新增資料庫,然後再寫入html檔案.

第二種:

webrequest訪問aspx頁面,然後獲取response流,得到的就是html

private

void

button1_click(

object

sender, system.eventargs e)

//

使用httpwebrequest獲得url的返回值

將aspx網頁以HTML形式儲存的幾個方法

aspx網頁以html形式儲存的幾個方法 第一種是模版替換 環境 microsoft net framework sdk v1.1 os windows server 2003 中文版 asp.net生成靜態html頁 在asp中實現的生成靜態頁用到的filesystemobject物件 在.net...

aspx網頁以HTML形式儲存的幾個方法

第一種是模版替換 環境 microsoft net framework sdk v1.1 os windows server 2003 中文版 asp.net生成靜態html頁 在asp中實現的生成靜態頁用到的filesystemobject物件 在.net中涉及此類操作的是system.io 以下...

aspx網頁以HTML形式儲存的幾個方法

第一種是模版替換 環境 microsoft net framework sdk v1.1 os windows server 2003 中文版 asp.net生成靜態 html頁 在asp中實現的生成靜態頁用到的filesystemobject物件 在.net中涉及此類操作的是system.io 以...

將ASPX檔案生成HTML檔案

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

Flash讀取ASPX網頁中的內容

function readfromaspx trace ture or false success 如果和伺服器成功連線則 if success 如果驗證動作成功則 trace this.conn is this.conn trace this recvid 1 sendid 1 conn 1 on...