HttpWebRequest HttpResponseHeader.location 的问题

songhuan 2008-09-18 01:05:50
HTTP/1.1 302 Moved Temporarily
Server: Apache-Coyote/1.1
ETag: 3cbvw6kgk9qlshgr
Location: http://www.ziprealty.com/global/searching.jsp?cKey=fs3swq26&target=http%3A%2F%2Fwww.ziprealty.com%2Fbuy_a_home%2Flogged_in%2Fsearch%2Fresults%2Findex.jsp%3FcKey%3Dz0m1vmcv%26page%3D1%26msg%3D
Content-Type: text/html;charset=utf-8
Content-Language: en
Content-Length: 0
Vary: Accept-Encoding
Expires: Thu, 18 Sep 2008 03:02:03 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Thu, 18 Sep 2008 03:02:03 GMT
Connection: keep-alive
Set-Cookie: NSC_qspevdujpoIUUQ=445235593660;expires=Thu, 18-Sep-08 03:02:51 GMT;path=/

上面是使用IE手动提交后返回的头,本人使用如下代码希望得到红的部分的Location,不知为何为空,请各位指教.


 Dim request As HttpWebRequest = CType(WebRequest.Create(surl1), HttpWebRequest)
request.CookieContainer = mySaveCookieContainer
request.Timeout = 100000000
'request.AllowAutoRedirect = True
Dim byteArray As Byte() = Encoding.UTF8.GetBytes(PostData)
request.Method = "POST"
request.ContentType = "application/x-www-form-urlencoded"
request.ContentLength = byteArray.Length

'post
Dim newStream As Stream = request.GetRequestStream()
newStream.Write(byteArray, 0, byteArray.Length)
newStream.Flush()
newStream.Close()


Dim res As HttpWebResponse = CType(request.GetResponse(), HttpWebResponse)
mySaveCookieContainer.Add(res.Cookies)
pageHtml = New StreamReader(res.GetResponseStream(), Encoding.UTF8).ReadToEnd()
Dim a = res.Headers(HttpResponseHeader.Location)
...全文
217 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
lisypro1 2011-10-26
  • 打赏
  • 举报
回复
也正好用,顶一下
lovehongyun 2008-09-18
  • 打赏
  • 举报
回复
解决了?
jf
yagebu1983 2008-09-18
  • 打赏
  • 举报
回复
没弄过,关注!!
up!!
songhuan 2008-09-18
  • 打赏
  • 举报
回复
自己解决
res.ResponseUri.OriginalString
songhuan 2008-09-18
  • 打赏
  • 举报
回复
再顶
songhuan 2008-09-18
  • 打赏
  • 举报
回复
不是,用代码获取,用IE手动提交只是为了监视结果
ZengHD 2008-09-18
  • 打赏
  • 举报
回复
用IE提交,然后用上面的代码获取??
songhuan 2008-09-18
  • 打赏
  • 举报
回复
自己顶。

110,539

社区成员

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

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

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