0

I am using Visual Studio Community (.Net 4.5). I have a simple form containing only a webBrowser control. When the form loads, I try to load a web page in the webBrowser control. This works when I load the page with Chrome. But it doesn't when I try with the webBrowser control. It says "Our website no longer supports out of date browsers". So I read many articles here and I tried to send a header in my query, defining my user agent to be the same as I get when I read it using javascript in Chrome. It Still doesn't work. Does anyone have a simple solution? I'm still new at all this. Here is my code. Thanks, you people are great!

private void Form1_Load(object sender, EventArgs e)
    {
        string website = "http://cpaquebec.ca/en/find-a-cpa/";
        webBrowser1.ScriptErrorsSuppressed = true;
        //webBrowser1.Navigate(website); //doesn't work
        string headers = "";
        headers += "User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.117 Safari/537.36\r\n";
        webBrowser1.Navigate(website,"_self",null,headers); //still won't work
    }
Richard L.
  • 5
  • 1
  • 5
  • You need to use fiddler to check if the header value you are passing from code is actually being passed to the site when you run the code. And if site does not support the browsers less than some specific version then there is nothing you can do about it. You can not change the behavior of site by mocking some value. If that was possible they wouldn't have implemented this behavior – Chetan Apr 21 '18 at 00:10
  • This is a common theme for Web browser control questions. Some page renders fine in chrome or firefox but not web browser control. Generally this issue is resolved by either injecting the xua compaitble meta tag into the document, or creating a registry entry associated with the application's executable that tells it to render with IE11 standards. There are several stack overflow questions with answers around these topics. – Alexander Ryan Baggett Apr 25 '18 at 20:02
  • The thing to remember is by default, if you don't tell it otherwise, the web browser control renders with IE 7 standards. – Alexander Ryan Baggett Apr 25 '18 at 20:03
  • Injecting the xua compatible meta tag into the document? How do I do that? I've read many questions and answers on this here, but they're explaining how to do it i javascript, or json, or vb, etc... Forgive me, I'm new at this. – Richard L. Apr 26 '18 at 17:53

0 Answers0