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

2021-04-17 00:23:27 字數 1501 閱讀 6942

第一種是模版替換:

環境: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);

// 寫檔案

trycatch(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**

html public "-//w3c//dtd html 4.0 transitional//en" >

showarticle

biaoti

content

author

html>

biaoti

content

author

html>

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

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

第二種:

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

private void button1_click(object sender, system.eventargs e)

//使用httpwebrequest獲得url的返回值

public string geturlvalue(string url)

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

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

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

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

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

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