G
Guest
How do i send a post string in c# .net cf
i need to send a multipart/form-data to a web server and get its response
i need to send a multipart/form-data to a web server and get its response
Alex Feinman said:Use HttpWebRequest.GetRequestStream and then write into that stream. Close
it when you are done. Might be easier to create a StreamWriter on it with
appropriate encoding
Something like this:
Uri target = new Uri(args[0]);
HttpWebRequest req = HttpWebRequest.Create(target) as HttpWebRequest;
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
Stream st = req.GetRequestStream();
StreamWriter wrt = new StreamWriter(st, Encoding.ASCII);
wrt.Write("destination=" + args[0]);
wrt.Write("&flags=14"); // Rich client (1 - basic client)
Console.Write("user: ");
wrt.Write("&username=" + Console.ReadLine());
Console.Write("password: ");
wrt.Write("&password=" + Console.ReadLine());
wrt.Write("&submit=submit");
wrt.Close();
st.Close();
HttpWebResponse rsp = req.GetResponse() as HttpWebResponse;
st = rsp.GetResponseStream();
StreamReader rdr = new StreamReader(st);
Console.WriteLine(rdr.ReadToEnd());
--
Alex Feinman
---
Visit http://www.opennetcf.org
Don Andrez said:How do i send a post string in c# .net cf
i need to send a multipart/form-data to a web server and get its response