Redirect方法
该方法使浏览器可以重新定位到另一个URL上,这样,当客户发出Web请求时,客户端的浏览器类型已经确定,客户被重新定位到相应的页面。如:
<html>
<head>
<title>Redirect示例</title>
</head>
<body>
<form aciton="formjump.asp" method="post">
<select name="wheretogo">
<option selected value="fun">Fun</option>
<option value="news">News</option>
<option value="sample">Sample</option>
</select>
<input type=submit name="jump" value="Jump">
</form>
</body>
</html>
以上是提交的表单,下面是处理表单的文件formjump.asp:
<%response.buff=true%>
<html>
<head>
<title>Redirect示例</title>
</head>
<body>
<%
thisurl="http://jefenet.yesky.net"
where=Request.form("wheretogo")
Select Case where
case "fun"
response.redirect thisurl & "/fun/default.asp"
case "news"
response.redirect thisurl & "/news/default.asp"
case "sample"
response.redirect thisurl & "/sample/default.asp"
End Select
%>
</body>
<html>
这个例子当用户选择了以后,按"Jump"按钮提交表单,服务器接到申请后调用formjump.asp判断后定位到相应的URL。不过这里有一点要注意,HTTP标题已经写入到客户浏览器,任何HTTP标题的修改必须在写入页内容之前,遇到这种问题时,可以如下做:
在文件的开始<@ Language=..>后写:
Response.Buffer=True
在结尾定:
Response.Flush
这里Flush是Response的一个方法,它必须是Buffer属性设置为True时才能使用,否则会产生一个运行模式错误。另外一个Clear方法也是用于清除被缓存的页面,同样要Buffer属性设置为True时才能使用。
该方法使浏览器可以重新定位到另一个URL上,这样,当客户发出Web请求时,客户端的浏览器类型已经确定,客户被重新定位到相应的页面。如:
<html>
<head>
<title>Redirect示例</title>
</head>
<body>
<form aciton="formjump.asp" method="post">
<select name="wheretogo">
<option selected value="fun">Fun</option>
<option value="news">News</option>
<option value="sample">Sample</option>
</select>
<input type=submit name="jump" value="Jump">
</form>
</body>
</html>
以上是提交的表单,下面是处理表单的文件formjump.asp:
<%response.buff=true%>
<html>
<head>
<title>Redirect示例</title>
</head>
<body>
<%
thisurl="http://jefenet.yesky.net"
where=Request.form("wheretogo")
Select Case where
case "fun"
response.redirect thisurl & "/fun/default.asp"
case "news"
response.redirect thisurl & "/news/default.asp"
case "sample"
response.redirect thisurl & "/sample/default.asp"
End Select
%>
</body>
<html>
这个例子当用户选择了以后,按"Jump"按钮提交表单,服务器接到申请后调用formjump.asp判断后定位到相应的URL。不过这里有一点要注意,HTTP标题已经写入到客户浏览器,任何HTTP标题的修改必须在写入页内容之前,遇到这种问题时,可以如下做:
在文件的开始<@ Language=..>后写:
Response.Buffer=True
在结尾定:
Response.Flush
这里Flush是Response的一个方法,它必须是Buffer属性设置为True时才能使用,否则会产生一个运行模式错误。另外一个Clear方法也是用于清除被缓存的页面,同样要Buffer属性设置为True时才能使用。