开发者

What UserAgent is reported by the WebBrowser control?

Just wondering what browser type the VB.NET reads 开发者_JAVA百科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.


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)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜