Response.AddHeader使用實例


  Response.AddHeader使用實例

1.文件下載,指定默認名
Response.AddHeader("content-type","application/x-msdownload"); // 限制類型
Response.AddHeader("Content-Disposition","attachment;filename=文件名稱.rar");// 下載后的文件名稱

2.刷新頁面
Response.AddHeader (“REFRESH”, ”60;URL=newpath/newpage.asp”)
這等同於客戶機端<META>元素:
<META HTTP-EQUIV=”REFRESH”, “60;URL=newpath/newpage.asp”>

3.頁面轉向
Response.Status = “302 Object Moved”
Response.Addheader “Location”, “newpath/newpage.asp”
這等同於使用Response.Redirect方法:
Response.Redirect “newpath/newpage.asp”

4.強制瀏覽器顯示一個username/口令對話框
Response.Status= “401 Unauthorized”
Response.Addheader “WWW-Authenticate”, “BASIC”
強制瀏覽器顯示一個username/口令對話框,然后使用BASIC驗證把它們發送回server(將在本書興許部分看到驗證方法)。

5.怎樣讓網頁不緩沖
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.Addheader "pragma","no-cache"
Response.Addheader "cache-control","private"
Response.CacheControl = "no-cache


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM