E
emcinerney
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()
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()