response.redirect "http://www2.google.com"
response.end
%>
response_cookies.asp
<%
'设置和读取cookies
response.cookies("time_now")=now()
response.write request.cookies("time_now")
%>
效果:
当访问http://10.1.43.238/course/response_cookies.asp时:
2002-9-1 16:20:40
response_buffer.asp
<%'response.buffer=true%>
<a href="a">a</a>
<%response.redirect "request_form.htm"%>
效果:
①.当关闭IIS的缓冲功能,访问该页面时出错
a
答复对象 错误 'ASP 0156 : 80004005'
头错
/course/response_buffer.asp,行3
HTTP 头已经写入到 客户浏览器。任何 HTTP 头的修改必须在写入页内容之前。
②.当关闭IIS的缓冲功能,去掉文件第一行的注释,则页面重定向成功
③.当打开IIS的缓冲功能,无论是否去掉文件第一行的注释,页面重定向都成功
3. Server
定义:可在服务器上使用不同实体函数,如在时间到达前控制脚本执行的时间。还可用来创建其他对象。
方法:
CreateObject:创建一个对象实例
HTMLEncode:将字符串转化为使用特别的HTML字符
MapPath:把虚拟路径转化成物理路径
URLEncode:把字符串转化成URL编码的
ScriptTimeout:在终止前,一个脚本允许运行的秒数
例子:
server_htmlencode.asp
<%
'html encode
response.write server.htmlencode("a""time_now")
%>
效果:
a"time_now
查看源文件时显示为:a"time_now
思考:为什么不是a""time_now这种效果?源文件是怎么了?
server_mappath.asp
<%
'mappath
response.write server.mappath("server_mappath.asp")
%>
效果:
G:\asp_www\test\course\server_mappath.asp
思考:如何获取站点根目录的实际路径?如何获取某个目录的实际路径?
server_urlencode.asp
<%
'url encode
response.write server.urlencode("a\time_now")
%>
效果:
a%5Ctime%5Fnow
4. Application
定义:用来存储、读取用户共享的应用程序信息,如可以用此对象在网站的用户间传送信息,当服务器重启后信息丢失。
方法:
Lock:防止其它用户访问Application集
Unlock:使其它用户可以访问Application集
事件:
| 对此文章发表了评论 |
