Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
hello helper
I have a problem in passing a string to the http post site. the code example i have converted string to byte and send it to the http site. The problem with that is the http post site does not understand the encoding. So I want to know is there a way i can pass a string without converting it to byte? Thank you very muchHere is the code i have:
byte [] bytes = System.Text.Encoding.Unicode.GetBytes(postData);
req.ContentLength = bytes.Length;
System.IO.Stream os = req.GetRequestStream();
os.Write(bytes, 0, bytes.Length);

Here's how to do a post using c#
private string HttpPost(string URI, string Parameters)
{
System.Net.WebRequest req = System.Net.WebRequest.Create(URI);
req.Proxy = new System.Net.WebProxy(ProxyString, true);req.ContentType = "application/x-www-form-urlencoded";
req.Method = "POST";byte [] bytes = System.Text.Encoding.ASCII.GetBytes(Parameters);
req.ContentLength = bytes.Length;System.IO.Stream os = req.GetRequestStream ();
os.Write (bytes, 0, bytes.Length);
os.Close ();System.Net.WebResponse resp = req.GetResponse();
if (resp== null) return null;System.IO.StreamReader sr = new System.IO.StreamReader(resp.GetResponseStream());
return sr.ReadToEnd().Trim();
}
Hope this helps,
ChiThey mostly come at night...mostly

![]() |
![]() |
![]() |

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |