How to make multiple or consecutive webrequests using the same connection or session
- From: emcinerney@xxxxxxxxx
- Date: 25 Apr 2005 17:06:10 -0700
I'm attempting to make WebRequest or HttpWebRequest requests to a
router's HTTP configuration interface. I cannot navigate directly to
the page I need because the router will automatically redirect
(somehow...I'm not sure if it's an http redirect or what) the request
to the router's initial page. So, after the first request, I need to
make a second request to navigate to the page I want. However, the
connection/session to the router seems to be lost and it again
redirects me to the router's initial page.
I have tried setting AllowAutoRedirect to False, but that didn't help.
Code Sample:
-----
Dim WR As HttpWebRequest
Dim SR As System.io.StreamReader
'This makes the first request
WR = CType(WebRequest.Create(sDestinationURI), HttpWebRequest)
WR.Credentials = New Net.NetworkCredential(Me.txtRouterUserID.Text,
Me.txtRouterPW.Text)
SR = New System.IO.StreamReader(WR.GetResponse.GetResponseStream)
Me.txtRouterHTMLSource.Text = WR.GetResponse.Headers.ToString()
Me.txtRouterHTMLSource.Text += SR.ReadToEnd
SR.Close()
'This makes the 2nd request, but I still get returned to the
'initial page.
WR = CType(WebRequest.Create(sDestinationURI), HttpWebRequest)
WR.Credentials = New Net.NetworkCredential(Me.txtRouterUserID.Text,
Me.txtRouterPW.Text)
SR = New System.IO.StreamReader(WR.GetResponse.GetResponseStream)
Me.txtRouterHTMLSource.Text = WR.GetResponse.Headers.ToString()
Me.txtRouterHTMLSource.Text += SR.ReadToEnd
SR.Close()
-----
Thanks for any and all help.
-Ed
.
- Follow-Ups:
- Re: How to make multiple or consecutive webrequests using the same connection or session
- From: Feroze [msft]
- Re: How to make multiple or consecutive webrequests using the same connection or session
- From: recoil@xxxxxxxxxxxxxxxx
- Re: How to make multiple or consecutive webrequests using the same connection or session
- Prev by Date: Re: StackOverflowException.
- Next by Date: Postback doesn't work with validators
- Previous by thread: Blob transfer - recommended approach?
- Next by thread: Re: How to make multiple or consecutive webrequests using the same connection or session
- Index(es):
Relevant Pages
|