What UserAgent is reported by the WebBrowser control?

穿精又带淫゛_ 提交于 2019-12-30 01:29:13

问题


Just wondering what browser type the VB.NET reads as when it visits a webpage. For instance on my website it shows a break down of all the different browsers that accessed my site.


回答1:


You don't provide much context to your question, but I assume that you're talking about the User Agent string that's sent when you use the WebBrowser control built into the .NET Framework.

Because that control just uses Internet Explorer to render the page, you'll see a User Agent string very similar to what you'd find if you visited the page using IE on the same computer. The IE string generically reports itself as Mozilla/4.0 compatible, but also gives the specific version of MSIE and lists the current version of Windows.

For example, running under the 64-bit version of Windows Server 2008 R2 with version 4.0 of the .NET Framework, I'm identified as follows whenever I surf to pages from the WebBrowser control:

Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.1)

By contrast, Internet Explorer on the same machine displays this as the User Agent string:

Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)

The only difference being that the .NET WebBrowser control reports itself as Internet Explorer version 7.0 (MSIE 7.0), instead of version 8.0 that is installed on the machine. This is because the control uses the IE 7 rendering engine, rather than the one in IE 8, for compatibility reasons. If you want, you can change this by editing a registry value.

To run a WebBrowser control in IE8 Standards Mode, use the following new value into the registry:

[(HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE)\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION] "MyApplication.exe" = dword 8000 (Hex: 0x1F40)

To run in IE7 Standards Mode, use the following registry value:

[(HKEY_CURRENT_USER or HKEY_LOCAL_MACHINE)\Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION] "MyApplication.exe" = dword 7000 (Hex: 0x1B58)



来源:https://stackoverflow.com/questions/4357947/what-useragent-is-reported-by-the-webbrowser-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!