tags:

views:

42

answers:

0

using the following code in win7 and vista all is ok:

 WebClient client = new WebClient();

 //specify an encoding for uploading.
 client.Encoding = System.Text.Encoding.ASCII;

 // Upload the data.
 var myReply = client.UploadValues(address,  data);
 reply = System.Text.ASCIIEncoding.ASCII.GetString(myReply);

however when running the same code on XP the if the data includes & all goes wrong! same data on w7 and it sends ok!

I seem to remember seeing this before and on XP needing to use lower case post and W7 Upper case POST as an additional option!!!

well is it me am I doing something wrong?

any idea?

this fixes the problem but why do I need it?

            OperatingSystem os = Environment.OSVersion;
            //Get version information about the os.
            Version vs = os.Version;

            if (os.Platform == PlatformID.Win32NT && vs.Major >= 6) //os Vista or above
            {
                var myReply = client.UploadValues(address, data);
                reply = System.Text.ASCIIEncoding.ASCII.GetString(myReply);
            }
            else
            {
                var myReply = client.UploadValues(address,"post", data);
                reply = System.Text.ASCIIEncoding.ASCII.GetString(myReply);
            }