頁面靜態化技術

2021-06-16 22:54:03 字數 1354 閱讀 2650

第一步:修改配置檔案,在system.web節點下新增: type中寫靜態化處理類名,path中寫要靜態化的頁面

第二步:編寫靜態化處理類:

using system;

using system.collections.generic;

using system.linq;

using system.web;

using system.io;

using bookshopmodels;

/// ///頁面靜態化技術

//4.獲取書籍物件

books book = bookshopbll.bookmanager.getbookbyid(convert.toint32(bookid));

//5.替換模板內容為真實書籍內容

.replace("[title]", book.title.tostring())

.replace("[bookid]", book.id.tostring())

.replace("[author]", book.author.tostring())

.replace("[publishname]", bookshopbll.publishermanager.getpublisherbyid(book.publisherid).name)

.replace("[publishdate]", book.publishdate.tostring())

.replace("[isbn]", book.isbn.tostring())

.replace("[unitprice]", book.unitprice.tostring())

.replace("[contentdescription]", book.contentdescription.tostring())

.replace("[toc]", book.toc.tostring());

//6.寫入靜態化內容頁面

using (streamwriter writer = new streamwriter(url))

}//解鎖

//7.跳轉到靜態的實際路徑(方法一)

context.response.redirect("~/bookdetails/"+bookid+".html");

//跳轉到靜態的實際路徑(方法二)

"~/bookdetails/" + bookid + ".html");

}public bool isreusable

}}

頁面靜態化技術

動態 所謂動態 一般來說去查詢資料庫,比如 特點 查詢資料庫,速度慢 接收引數,安全性要注意 sql注入 不利於seo搜尋引擎優化。靜態 比如 這個就是乙個靜態 特點 不查詢資料庫,速度快 不接收引數,安全性高 利於seo 偽靜態 從形式上看是乙個靜態頁面,但是實際上對應乙個動態頁面,特點 本身需要...

動態頁面靜態化技術

比如 動態url 與靜態url http hi.baidu.com ycosxhack blog37.htm哪種會更好?自然是後者了!其中的好處是迎合了搜尋引擎的要求,靜態頁面更易被搜尋引擎收錄。且這樣將會提高了 的移植性。從黑客角度來看,黑客更喜歡http hi.baidu.com ycosxha...

PHP頁面靜態化技術

php頁面的靜態化很有必要,尤其是在 cms系統中,一些內容一旦生成,基本上不會有變化,這時如果用 html 將頁面靜態化,無疑會減少服務其解析php 頁面的負擔。以下是看書學來的php 靜態化技術,記錄之以備不時之需。無論是利用框架還是簡單的指令碼,原理基本一致 就是利用php 進行檔案操作,替換...