是否能用HttpWebRequest(用同一个Session_Id)同时向同一网站不同页面发送请求

ldzy07 2010-03-25 03:01:36
是否能用HttpWebRequest(用同一个Session_Id)同时向同一网站不同页面发送请求,这样做会存在什么问题,会导致什么后果?这些请求的影响会不会造成干扰?如果存在干扰如何解决?小弟先谢过了!
...全文
219 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
hb1122 2010-04-14
  • 打赏
  • 举报
回复
碰到新问题了?!
ldzy07 2010-03-31
  • 打赏
  • 举报
回复
     Dim byteRequest1 As Byte() = Encoding.Default.GetBytes("synid=-1&sportid=1&oddsStyle=&dt=4&scope=1&fsynid=0")
Dim httpWebRequest1 As HttpWebRequest
Dim webResponse1 As HttpWebResponse
httpWebRequest1 = CType(WebRequest.Create(Me.urls(1) & "/webroot/restricted/oddsdisplay/Main1DataFrame.aspx"), HttpWebRequest)
'设置请求的SessionId
Dim co1 As CookieContainer = New CookieContainer()
co1.SetCookies(New Uri(Me.urls(1) & "/webroot/restricted/oddsdisplay/Main1DataFrame.aspx"), Me.cookies(1))
httpWebRequest1.CookieContainer = co1
httpWebRequest1.ContentType = "application/x-www-form-urlencoded"
httpWebRequest1.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"
'httpWebRequest.Referer = "http://" & Me.Url & "/hometop.aspx?ip=&p="
httpWebRequest1.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 1.1.4322)"
httpWebRequest1.Method = "Post"
httpWebRequest1.Timeout = 2000
httpWebRequest1.ContentLength = byteRequest1.Length
httpWebRequest1.AllowAutoRedirect = False '是否自动重定向
httpWebRequest1.ServicePoint.Expect100Continue = False
Dim noCachePolicy As New HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore)
httpWebRequest1.CachePolicy = noCachePolicy
Dim stream1 As Stream
stream1 = httpWebRequest1.GetRequestStream()
stream1.Write(byteRequest1, 0, byteRequest1.Length)
stream1.Close()
webResponse1 = CType(httpWebRequest1.GetResponse(), HttpWebResponse)
Dim getdata1 As String = New StreamReader(webResponse1.GetResponseStream(), Encoding.UTF8).ReadToEnd()
ldzy07 2010-03-31
  • 打赏
  • 举报
回复
Dim byteRequest1 As Byte() = Encoding.Default.GetBytes("synid=-1&sportid=1&oddsStyle=&dt=4&scope=1&fsynid=0")
Dim httpWebRequest1 As HttpWebRequest
Dim webResponse1 As HttpWebResponse
httpWebRequest1 = CType(WebRequest.Create(Me.urls(1) & "/webroot/restricted/oddsdisplay/Main1DataFrame.aspx"), HttpWebRequest)
'设置请求的SessionId
Dim co1 As CookieContainer = New CookieContainer()
co1.SetCookies(New Uri(Me.urls(1) & "/webroot/restricted/oddsdisplay/Main1DataFrame.aspx"), Me.cookies(1))
httpWebRequest1.CookieContainer = co1
httpWebRequest1.ContentType = "application/x-www-form-urlencoded"
httpWebRequest1.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"
'httpWebRequest.Referer = "http://" & Me.Url & "/hometop.aspx?ip=&p="
httpWebRequest1.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 1.1.4322)"
httpWebRequest1.Method = "Post"
httpWebRequest1.Timeout = 2000
httpWebRequest1.ContentLength = byteRequest1.Length
httpWebRequest1.AllowAutoRedirect = False '是否自动重定向
httpWebRequest1.ServicePoint.Expect100Continue = False
Dim noCachePolicy As New HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore)
httpWebRequest1.CachePolicy = noCachePolicy
Dim stream1 As Stream
stream1 = httpWebRequest1.GetRequestStream()
stream1.Write(byteRequest1, 0, byteRequest1.Length)
stream1.Close()
webResponse1 = CType(httpWebRequest1.GetResponse(), HttpWebResponse)
Dim getdata1 As String = New StreamReader(webResponse1.GetResponseStream(), Encoding.UTF8).ReadToEnd()
ldzy07 2010-03-31
  • 打赏
  • 举报
回复
Dim byteRequest1 As Byte() = Encoding.Default.GetBytes("synid=-1&sportid=1&oddsStyle=&dt=4&scope=1&fsynid=0")
Dim httpWebRequest1 As HttpWebRequest
Dim webResponse1 As HttpWebResponse
httpWebRequest1 = CType(WebRequest.Create(Me.urls(1) & "/webroot/restricted/oddsdisplay/Main1DataFrame.aspx"), HttpWebRequest)
'设置请求的SessionId
Dim co1 As CookieContainer = New CookieContainer()
co1.SetCookies(New Uri(Me.urls(1) & "/webroot/restricted/oddsdisplay/Main1DataFrame.aspx"), Me.cookies(1))
httpWebRequest1.CookieContainer = co1
httpWebRequest1.ContentType = "application/x-www-form-urlencoded"
httpWebRequest1.Accept = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/x-shockwave-flash, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"
'httpWebRequest.Referer = "http://" & Me.Url & "/hometop.aspx?ip=&p="
httpWebRequest1.UserAgent = "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Maxthon; .NET CLR 1.1.4322)"
httpWebRequest1.Method = "Post"
httpWebRequest1.Timeout = 2000
httpWebRequest1.ContentLength = byteRequest1.Length
httpWebRequest1.AllowAutoRedirect = False '是否自动重定向
httpWebRequest1.ServicePoint.Expect100Continue = False
Dim noCachePolicy As New HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore)
httpWebRequest1.CachePolicy = noCachePolicy
Dim stream1 As Stream
stream1 = httpWebRequest1.GetRequestStream()
stream1.Write(byteRequest1, 0, byteRequest1.Length)
stream1.Close()
webResponse1 = CType(httpWebRequest1.GetResponse(), HttpWebResponse)
Dim getdata1 As String = New StreamReader(webResponse1.GetResponseStream(), Encoding.UTF8).ReadToEnd()
  • 打赏
  • 举报
回复
正常写代码没有任何问题。谁知道你怎么写的?
ldzy07 2010-03-30
  • 打赏
  • 举报
回复
你分析得有道理,但是这他们不存在先后关系,随便访问那个都行,我用线程做的,即使这个线程只访问一个页面,如果没有Sleep的话他返回的结果就经常中是一个“.“(圆点)没其他了,如果用多线程每个线程访问不同的页面,但是他不是同时发送请求的话数据就正常否则就是“.“,那位大哥大姐帮帮忙啊,现在都急死我了!
ldzy07 2010-03-26
  • 打赏
  • 举报
回复
自己顶一下
iwome 2010-03-26
  • 打赏
  • 举报
回复

我觉得这个得取决于服务器端的设置,如果你访问的2个页面Session保存的数据有相关性的话可能就有问题,比如按照顺序应该先第一个页面,然后第二个页面。如果Session里面这2个页面存在逻辑关系那可能会出问题。如果两个页面没有逻辑关系,我觉得就没啥问题。

其实不如,你先做了试试看看啥结果。
ldzy07 2010-03-25
  • 打赏
  • 举报
回复
这个我知道,我是想问这两HttpWebReuest对象能不能同时发送请求!如果同时发送会存在什么问题?
  • 打赏
  • 举报
回复
创建两个HttpWebRequest(用同一个Session_Id)。

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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