這樣就少了一個流程了!也縮短了服務器->客戶機->服務器互相訪問的時間!但是值得提醒你注意的一點的是Server.transfer中帶的地址最好是html文件或asp文件,不要是第三方加載的東西,比如說PHP,如果那樣的話,程序是不能正常執行的,因為轉向的文件被直接送給ASP的引擎解析了(唉,微軟的東西教人如何說呢?不知道這點是沒有考慮到,還是微軟的霸氣),你將得不到結果的!在下面的程序中,我們將像你展示這點 讓我們看看下面的代碼: (文件:Response.asp:)
< html> < head> < meta http-equiv="Content-Type" content="text/html; charset=gb2312"> < META NAME="Author" CONTENT="蒲俊杰"> < META NAME="Keywords" CONTENT="ASP,www.aspcn.com"> < title>Response測試 < /head> < body> < %Response.Redirect "test.php"%> < /body> < /html>
test.php文件的代碼如下:
< html> < head> < meta http-equiv="Content-Type" content="text/html; charset=gb2312"> < META NAME="Author" CONTENT="蒲俊杰"> < META NAME="Keywords" CONTENT="ASP,PHP,www.aspcn.com"> < title>Response測試< /title> < /head> < body> < ? echo " 這是一個測試,你好呀!歡迎你訪問我們的網站< a href=http://www.aspcn.com>www.aspcn.com " ; ?> < /body> < /html>
好了,我們測試一下上面的代碼,看到結果了嗎?再讓我們來看看Server.Transfer的運用語句,代碼如下: Server.asp(其實直接套用Response.asp就可以了):
< html> < head> < meta http-equiv="Content-Type" content="text/html; charset=gb2312"> < META NAME="Author" CONTENT="蒲俊杰"> < META NAME="Keywords" CONTENT="ASP,www.aspcn.com"> < title>Response測試< /title> < /head> < body> < %Server.Transfer "test.php"%> < /body> < /html>
執行一下Server.asp!咦,怪了,什么都沒有嗎!但是你看看被IE解釋后的代碼,代碼如下(注意千萬不要被我下面的使用在html中的注釋語句搞糊涂了):
|