How to install user agent in GeckoFX?

After using the webbrowser control for some time, I decided to try gecko because of the web browser issues I experienced, low speed and poor performance. I downloaded the latest version of geckofx (16.0.0.2) and xulrunner (16.0.2) and created a geckoWebbrowser control. When I tried to go to the web page, I got javascript.alert, which is not supported by my web browser and that I should use firefox> 2.0.0.2, which, of course, is ridiculous. The problem was that I found that the useragent string found was "Mozilla / 5.0 (Windows NT 6.1; WOW64; rv: 16.0) Gecko // 16.0" instead of the usual firefox line "Mozilla / 5.0 (Windows NT 6.1; WOW64; rv : 18.0) Gecko / 20100101 Firefox / 18.0 ". '20100101' and 'Firefox'missing from the useragent line of the control. Is there a way to change it using C #? I am using C # winforms.net 4.5.

+5
source share
1 answer

From http://www.webprogrammingblog.com/geckofx-set-user-agent/ :

public Form1()
{
    InitializeComponent();
    Gecko.Xpcom.Initialize("c:\\tools\\xulrunner");
    myBrowser = new GeckoWebBrowser();
    myBrowser.Parent = this;
    myBrowser.Dock = DockStyle.Fill;

    string sUserAgent = "Mozilla/5.0 (Windows; U; Windows NT 6.1; pl; rv:1.9.1) Gecko/20090624 Firefox/3.5 (.NET CLR 3.5.30729)";
     Gecko.GeckoPreferences.User["general.useragent.override"] = sUserAgent;
}
+11
source

All Articles