Hi Is it possible to pass parameters with a http get request if so how should I then do it. I have found a http post requst http://msdn.microsoft.com/en-us/library/debx8sh9.aspx it that example the string postData is send to a webserver, I would like to do the same using GET instead. Google found this example on http get http://support.microsoft.com/kb/307023, however there isnt send any parameters to the web server.
+6
A:
In a GET request, you pass parameters as part of the query string.
Dim sUrl As String = "http://somesite.com?var=12345"
EndangeredMassa
2009-02-05 07:20:53
If you enter the complete url including the parameters in the adresse bar of iexplore, do I then get the same response as is make a http request get from c#
CruelIO
2009-02-05 09:05:03
That should be the case.
EndangeredMassa
2009-02-05 15:22:51
+9
A:
First WebClient
is easier to use; GET arguments are specified on the query-string - the only trick is to remember to escape any values:
string address = string.Format(
"http://foobar/somepage?arg1={0}&arg2={1}",
Uri.EscapeDataString("escape me"),
Uri.EscapeDataString("& me !!"));
string text;
using (WebClient client = new WebClient())
{
text = client.DownloadString(address);
}
Marc Gravell
2009-02-05 07:27:08