Using System.Net.WebClient.UploadString to HTTP POST

  • Thread starter Thread starter Rlake
  • Start date Start date
R

Rlake

I am having trouble with my ADSL router, so am writing a simple app to
'click' the Reset button on its HTML configuration page for me whenever
the connection drops out.

I am trying to send a HTTP POST to it using System.Net.WebClient and am
wondering if I am on the right track or not. Have written the
following (got the Authorization header value from a HTTP sniffer to
see what was being POSTed when I clicked the button):

Dim x As New System.Net.WebClient
x.Headers.Add("AUTHORIZATION", "Basic zWatZW46adpqQBdnbmQ=")
x.Headers.Add("Connection", "Keep-Alive")
Dim Result As String
Result = x.UploadString("http://192.168.2.2/st_stats.html",
"reset=Reset")

With the above I get the exception:
"Keep-Alive and Close may not be set using this property. Parameter
name: value"

When I remove the Keep-Alive header I get the exception:
"Unable to read data from the transport connection: An existing
connection was forcibly closed by the remote host."

Am I on the right track? What else am I missing?
 
Back
Top