1

I have written an application which loads a website and invokes a click event on certain buttons.

Im using the WPF WebBrowser control and attaching to the LoadCompleted event.

var Document = this.MyBrowser.Document as mshtml.HTMLDocument;
var InputTags = Document.getElementsByTagName("INPUT");

foreach (HtmlElement tag in InputTags)
{
    if (tag.Name == "commit" && tag.GetAttribute("value") == "Activate")
    {
        tag.InvokeMember("Click");
    }
}

This code works perfectly fine on most pages, however it seems the WebBrowser control is not a fully compliant browser and does not render all websites correctly.

On one site im just getting a few images and a grey background. Looking at the source it hasnt loaded most of the page.

The page renders fine in Chrome, Firefox and IE.

Any other browsers i can use that will give me the same functionality that im using in my code example above?

The user agent of the control is reported as:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1; Win64; x64; Trident/7.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.3; Tablet PC 2.0; Zoom 3.6.0; wbx 1.0.0)

This was marked as a duplicate. Upgrading the browser to use IE11 emulation didnt resolve the issue.

CathalMF
  • 9,705
  • 6
  • 70
  • 106
  • @mjwills Ive updated the question with the user agent. – CathalMF Mar 15 '18 at 12:01
  • 1
    Possible duplicate of [Use latest version of Internet Explorer in the webbrowser control](https://stackoverflow.com/questions/17922308/use-latest-version-of-internet-explorer-in-the-webbrowser-control) – mjwills Mar 15 '18 at 12:02
  • @mjwills That didnt fix my problem – CathalMF Mar 15 '18 at 12:43
  • @mjwills The user agent remains the same. If i go to https://www.whatsmybrowser.org/ it says im using IE11 – CathalMF Mar 15 '18 at 12:48
  • I would recommend to switch to some more advanced control, e.g. CefSharp – vasek Mar 15 '18 at 12:53
  • @mjwills Well it is. Here is a screenshot showing the browser is 11 and the same user agent string. https://imgur.com/nxutWOu – CathalMF Mar 15 '18 at 12:53
  • @mjwills No its not intranet and i dont have control over the source. Yes ive set the registry string but even without the registry string the Browser still reports as 11. – CathalMF Mar 15 '18 at 12:59
  • @mjwills Sorry, my mistake, there was a typo in my executable name the registry. It is now reporting the updated user agent and correctly displaying the page. Thanks. – CathalMF Mar 15 '18 at 13:02

0 Answers0