i was wondering how to post data from c# form to a php using geckoWebBrowser?
I have done it with IE browser on form
public Form1()
{
InitializeComponent();
String postdata = "data=somedata";
System.Text.Encoding a = System.Text.Encoding.UTF8;
byte[] byte1 = a.GetBytes(postdata);
webBrowser1.Navigate("somepage.php", "", byte1, "Content-Type: application/x-www-form-urlencoded");
}
But how to do it with geckoWebBrowser1.Navigate?
The method
GeckoWebBrowser.Navigate()passes its parameters to ansIWebNavigationinstance, which is theXPCOMinterface for running a browser instance, in this case usingXULRunner 1.8(which is pretty old).Unfortunately, the
Navigate()method of theGeckoWebBrowserdoes not supply an overload forpostData; it simply passesIntptr.Zerofor that argument.I can’t test it, but if you create a new method like this in
GeckoWebBrowser.cs, you can call it with a string containing post data:Please note that the
LoadURImethod accepts annsIInputStreamparameter, which I do not know. Try to find the parameter type and how to instantiate that, and fix theCreateStreamFromString()method to return and instantiate the right type.Also check out the documentation for the
postDataparameter:But perhaps you just want to use a
WebClientorHttpClient(.NET 4.5 only) class if this is only for posting data to some URL.