Hi,
I want to Navigate to a site "anysite.php" and sending postdata. If I call Navigate method "anysite.php" is shown. But there is no postdata.
Source Code:
String postdata = "u=idcode"; System.Text.ASCIIEncoding a = new System.Text.ASCIIEncoding(); ubyte[] byte1 = a.GetBytes(postdata);webBrowser1.Navigate(
"anysite.php", "_SELF",byte1, "");The webbrowser shows Method=post instead of method=get but contains no postdata.
Can anyone help me

Postdata in webbrowser.Navigate
vo_yage
Thanks a lot, everything work
If targetFrameName parameter is "_SELF" (like in first post) url is opened innew browser window, so I used empty parameter to load url to existing WebBrowser control
I use this code:
string PostDataStr = "qwe=1&asd=2";
byte[] PostDataByte = Encoding.UTF8.GetBytes(PostDataStr);
string AdditionalHeaders = "Content-Type: application/x-www-form-urlencoded" + Environment.NewLine;
WebBrowser.Navigate("http://localhost/a.php", "", PostDataByte, AdditionalHeaders)
PS: by the way, the code in C# =)
SlinkingFerret
What dsinay said was true. However, use the below line otherwise it won't work
webBrowser1.Navigate("anysite.php", "_SELF",byte1, "Content-Type: application/x-www-form-urlencoded\r\n" );
SHASHIVRAT
Hi,
This is more related to windows forms, Can you please post this on http://forums.microsoft.com/MSDN/default.aspx forumgroupid=2&siteid=1
Thanks,
Varun
sanjeewa
Hi,
you need to add "Content-Type: application/x-www-form-urlencoded" to the additionalHeaders parameter. so your code would look like this
webBrowser1.Navigate("anysite.php", "_SELF",byte1, "Content-Type: application/x-www-form-urlencoded" );
you might also need to change the encoding to use UTF8.
you can use something like this
String postdata = "u=idcode";
System.Text.
Encoding a = System.Text.Encoding.UTF8; byte[] byte1 = a.GetBytes(postdata);webBrowser1.Navigate("anysite.php", "_SELF",byte1, "Content-Type: application/x-www-form-urlencoded" );
hope that helps you.
Regards
Damian