tags:

views:

790

answers:

1

i think i am going a bit crazy, when i test this on my local webserver, it works fine when i go out to the live website, it returns a blank string instead of the data i am expecting

i am not that familiar with C#, so i just wanted to check i am doing things right. the data is just plain ascii text

 wc = new WebClient();
 wc.Headers.Add("Content-Type", "application/x-www-form-urlencoded");
 response = wc.UploadData(this.urlUpdate, Encoding.ASCII.GetBytes("data=" + HttpUtility.UrlEncode(buf.ToString())));

 s = Encoding.ASCII.GetString(response);
+4  A: 

It really depends what you are trying to do... I'm not sure, for example, why you are url-encoding data in the body. An easier way to post key/value pairs is with UploadValues;

NameValueCollection inputs = new NameValueCollection();
string value = ...
inputs.Add("data", value);
webClient.UploadValues(address, inputs);
Marc Gravell
it hasn't solved the problem, but is a nicer way of coding the solution. i guess i coded it the way i did due to unfamiliarity with the C# api
bumperbox