检测其中的IE浏览器版本安装在C#您的操作系统? [英] Detecting which version of IE is installed on your OS in C#?
问题描述
我通项manintaining一个窗口服务,programmatcially生成一个HttpWebRequest和HttpWebResponse对象检索请求的响应消息。
I am currenting manintaining a windows service that programmatcially generates a HttpWebRequest and HttpWebResponse objects for retrieving the response message of the request.
在HttpWebRequest的的的UserAgent
属性是很难codeD使用IE 6作为浏览器的代理。是一种方法来programmatcially检测哪个版本的IE安装托管服务的服务器上?
The UserAgent
property of the HttpWebRequest was hard coded to use IE 6 as the browser agent. Is the a way to programmatcially detect which version of IE is installed on the server hosting the service?
这是目前托管在Windows Server 2003的计算机上,并可能会在Windows Server 2008的计算机上安装。
It is currently hosted on a Windows Server 2003 machine and might be installed on a Windows Server 2008 machine.
推荐答案
您也可以从WebBrowser控件本身提取它,如果你已经创建了一个:
you can also extract it from the WebBrowser control itself, if you have created one:
WebBrowser browser = new WebBrowser();
Version ver = browser.Version;
警告:这必须由STA线程调用,否则就抛出一个异常。 这可以在MSTest的清理code,这是MTA,遇到不STA。
Warning: this must be called from STA thread, otherwise it throws an exception. This can be encountered in MSTest cleanup code, which is MTA, not STA.
这篇关于检测其中的IE浏览器版本安装在C#您的操作系统?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!