M
Manuel
I have an asp page ("test.asp") that presents the data it receives from a
post.When I try the following code, test.asp doesn't return the values
(supposedly) posted to it. If I make a web page with a form and the values,
test.asp reports them fine.
----------------------------
Dim thePost As String = "Variable1=Value1&Variable2=Value2&Variable3=Value3"
Dim thePage As Byte()
Dim MyWebClient As New System.Net.WebClient
thePage = MyWebClient.UploadData("http://localhost/test.asp",
System.Text.Encoding.ASCII.GetBytes(thePost))
----------------------------
Does anyone have an idea why the WebClient is not posting the data?
.... I made some progress, but encountered other problems
I made a successful post using the following code:
----------------------------
Dim oNameValues As New System.Collections.Specialized.NameValueCollection
oNameValues.Add("Variable1", "Value1")
oNameValues.Add("Variable2", "Value2")
oNameValues.Add("Variable3", "Value3")
Dim thePage As Byte()
Dim MyWebClient As New System.Net.WebClient
thePage = MyWebClient.UploadValues("http://localhost/test.asp", "POST",
oNameValues)
----------------------------
The problem is that I cannot change the Content-Type. If I try to change the
content type with:
MyWebClient.Headers.Add("Content-Type", "multipart/form-data")
I get the following error at the .UploadValues line:
----------------------------
An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
Additional information: The Content-Type header cannot be changed from its
default value for this request.
----------------------------
How can I make a successful post using "Content-Type = multipart/form-data"?
PS. Sorry for the cross-post, I first submitted it to the adonet group by
mistake.
post.When I try the following code, test.asp doesn't return the values
(supposedly) posted to it. If I make a web page with a form and the values,
test.asp reports them fine.
----------------------------
Dim thePost As String = "Variable1=Value1&Variable2=Value2&Variable3=Value3"
Dim thePage As Byte()
Dim MyWebClient As New System.Net.WebClient
thePage = MyWebClient.UploadData("http://localhost/test.asp",
System.Text.Encoding.ASCII.GetBytes(thePost))
----------------------------
Does anyone have an idea why the WebClient is not posting the data?
.... I made some progress, but encountered other problems
I made a successful post using the following code:
----------------------------
Dim oNameValues As New System.Collections.Specialized.NameValueCollection
oNameValues.Add("Variable1", "Value1")
oNameValues.Add("Variable2", "Value2")
oNameValues.Add("Variable3", "Value3")
Dim thePage As Byte()
Dim MyWebClient As New System.Net.WebClient
thePage = MyWebClient.UploadValues("http://localhost/test.asp", "POST",
oNameValues)
----------------------------
The problem is that I cannot change the Content-Type. If I try to change the
content type with:
MyWebClient.Headers.Add("Content-Type", "multipart/form-data")
I get the following error at the .UploadValues line:
----------------------------
An unhandled exception of type 'System.Net.WebException' occurred in
system.dll
Additional information: The Content-Type header cannot be changed from its
default value for this request.
----------------------------
How can I make a successful post using "Content-Type = multipart/form-data"?
PS. Sorry for the cross-post, I first submitted it to the adonet group by
mistake.