AddHeader 方法以确定值增加一个HTML头(header)。此方法总是给response增加一个新的头,而不提换掉现存的同名的头,一个头增加之后就无法删除。
文件下载,指定默认名
Response.AddHeader(”content-type”,”application/x-msdownload”);
Response.AddHeader(”Content-Disposition”,”attachment;filename=要下载的文件名.rar”);
刷新页面
Response.AddHeader “REFRESH”, "60;URL=http://www.biye5u.com/article/”
这等同于客户机端<META>元素:
<META HTTP-EQUIV=”REFRESH”, "60;URL=http://www.biye5u.com/article/”
页面转向
Response.Status = “302 Object Moved”
Response.Addheader “Location”, "http://www.biye5u.com/article/”
这等同于使用Response.Redirect方法:
Response.Redirect “http://www.biye5u.com/article/”
强制浏览器显示一个用户名/口令对话框
Response.Status= “401 Unauthorized”
Response.Addheader “WWW-Authenticate”, "BASIC”
强制浏览器显示一个用户名/口令对话框,然后使用BASIC验证把它们发送回服务器(将在本书后续部分看到验证方法)。
如何让网页不缓冲
Response.Expires = 0
Response.ExpiresAbsolute = Now() - 1
Response.Addheader “pragma”,”no-cache”
Response.Addheader “cache-control”,”private”
Response.CacheControl = “no-cache"