0

I have a console application which I use to download HTML from a website and compare this HTML to another that I have in a blob. For this, I'm using the WebBrowser component from Windows Forms. Everything works fine when I'm running the application on my machine, but when I migrate the console application to run on other machine, the HTML downloaded in the run time is different in some aspects. For example: In the base HTML that I have on the blob, the element is like this:

<FORM><INPUT id=ni value=Test type=hidden name=ni>

If I run on my machine, the HTML element is equivalent in the downloaded document by the browser, but in the other machine the element comes like this:

<FORM><INPUT id=ni type=hidden value=Test name=ni>

As you can see the order of the attributes is different. This is not a relevant change to me, but I'm wondering why this is happening if it's the same program running on both machines?

The code:

 private void OnDocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
 { 
     var html = _browser.Document.Body.InnerHtml;
     //This is getting different.
 }
MC10
  • 552
  • 1
  • 12
  • 26
gog
  • 11,788
  • 23
  • 67
  • 129
  • Are you using the same browser on different machines? Different browsers will generate different HTML output. – MC10 Jul 23 '15 at 18:22
  • @MC10 well I dont know, because im just instantiating the WebBroser component without specifing no browser. How do i check for it? – gog Jul 23 '15 at 18:23
  • Oops, nevermind. You aren't using a browser. As for why it is different on different machines when using the WebBrowser control, I'm not sure. Maybe it is rendering it in a different way. This link might have some good info on that: http://blogs.msdn.com/b/patricka/archive/2015/01/12/controlling-webbrowser-control-compatibility.aspx – MC10 Jul 23 '15 at 18:30

1 Answers1

1

The WebBrowser in .Net uses the version of IE installed on the machine. It could be that the page you are getting is different based on the user agent of the browser. Just open IE on both machines and view the source of the page to confirm it isn't your code that is causing the difference.

TylerReid
  • 481
  • 4
  • 18
  • You got the point. My machine runs the IE11 and the other runs IE8. Actually the best thing to do is update the IE8 to 11? – gog Jul 23 '15 at 18:53
  • You might just want to try using something other than the browser. There could still be weirdness but try this: http://stackoverflow.com/questions/599275/how-can-i-download-html-source-in-c-sharp – TylerReid Jul 23 '15 at 19:26