By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,659 Members | 940 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,659 IT Pros & Developers. It's quick & easy.

Posting to specific form field with C#

P: n/a
I am posting data to a form using the code below (from a console app). My
problem is that I'm posting my data as a generic request stream, and the page
is expecting the data to have come from a specific form field (<textarea
name="xml">). How do I modify the following code so that when the recieving
page receives the post, my stream gets read in as Request.Form["xml"]?

bytes = System.Text.Encoding.ASCII.GetBytes(strXML);
objHttpWebRequest.Method = "POST";
objHttpWebRequest.ContentLength = bytes.Length;
objHttpWebRequest.ContentType = "text/xml; encoding='utf-8'";
objRequestStream = objHttpWebRequest.GetRequestStream();
objRequestStream.Write(bytes, 0, bytes.Length);
objRequestStream.Close();
Oct 16 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Try Webclient.UploadValues instead. It will do this for you...
--
Patrice
"Dan" <da*********@newsgroup.nospama écrit dans le message de groupe de
discussion : 71**********************************@microsoft.com...
I am posting data to a form using the code below (from a console app). My
problem is that I'm posting my data as a generic request stream, and the
page
is expecting the data to have come from a specific form field (<textarea
name="xml">). How do I modify the following code so that when the
recieving
page receives the post, my stream gets read in as Request.Form["xml"]?

bytes = System.Text.Encoding.ASCII.GetBytes(strXML);
objHttpWebRequest.Method = "POST";
objHttpWebRequest.ContentLength = bytes.Length;
objHttpWebRequest.ContentType = "text/xml; encoding='utf-8'";
objRequestStream = objHttpWebRequest.GetRequestStream();
objRequestStream.Write(bytes, 0, bytes.Length);
objRequestStream.Close();

Oct 16 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.