如何取得response.redirect 中的转身网址??

lj9969 2005-03-14 04:58:02
下面是一个取得网页的源代码,但当网页是一个转向时(response.redirect),怎样才能取得response.redirect 后面的网址呢???
请高手指教:
<%@Page Language="C#" Debug="true"%>
<%@Import NameSpace="System.Net"%>
<%@Import NameSpace="System.IO"%>
<script language="C#" runat="Server">
string sException=null;
public string GetHttpData(string sUrl){
string sRslt=null;
string urls;
WebResponse oWebRps=null;
WebRequest oWebRqst=WebRequest.Create(sUrl);
oWebRqst.Timeout=50000;
try{
oWebRps=oWebRqst.GetResponse();

}
catch(WebException e){
sException=e.Message.ToString();
}
catch(Exception e){
sException=e.ToString();
}
finally{
if(oWebRps!=null){
StreamReader oStreamRd=new StreamReader(oWebRps.GetResponseStream(),System.Text.Encoding.GetEncoding("GB2312"));
sRslt=oStreamRd.ReadToEnd();
oStreamRd.Close();
oWebRps.Close();
}
}
return sRslt;
}
</script>
<%
TimeSpan oStartTime=DateTime.Now.TimeOfDay;
string s=HttpUtility.HtmlEncode(GetHttpData("http://test.fzclx.com/caixi/test.asp")).Replace("\n","\n<br>");
Response.Write(s);
Response.Write("<br><br>\r\n执行时间:" + DateTime.Now.TimeOfDay.Subtract(oStartTime).TotalMilliseconds.ToString() + " 毫秒");
%>
...全文
160 12 打赏 收藏 转发到动态 举报
写回复
用AI写文章
12 条回复
切换为时间正序
请发表友善的回复…
发表回复
caixicn 2005-03-16
  • 打赏
  • 举报
回复
顶呀.
caixicn 2005-03-15
  • 打赏
  • 举报
回复
和机耕.顶.
caixicn 2005-03-15
  • 打赏
  • 举报
回复
能帮我直接写出来么??
yongwc 2005-03-15
  • 打赏
  • 举报
回复
直接访问 oWebRps.ResponseUri 属性即可
yongwc 2005-03-15
  • 打赏
  • 举报
回复
如果是在服务端调用 response.redirect(targetUrl) 方法的话,获取的本身就是targetUrl 的内容啊
caixicn 2005-03-14
  • 打赏
  • 举报
回复
T
caixicn 2005-03-14
  • 打赏
  • 举报
回复
顶顶顶.
lj9969 2005-03-14
  • 打赏
  • 举报
回复
在线苦苦等待。
还没有结果在那显示。。
哎哦,望着电脑,
拍拍头脑。
郁闷等待。。
caixicn 2005-03-14
  • 打赏
  • 举报
回复
顶,顶
caixicn 2005-03-14
  • 打赏
  • 举报
回复
顶.
caixicn 2005-03-14
  • 打赏
  • 举报
回复
楼上的高手,能不能写一下?
yongwc 2005-03-14
  • 打赏
  • 举报
回复
先分析获取到的网页数据,看是否redirect,如果是,分析出重定向的网址,然后获取咯

110,499

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧