Determine which version of IE is installed on your OS in C #?

I am currently using a Windows service that programmatically generates HttpWebRequest and HttpWebResponse objects to receive a request response message.

The UserAgent property for HttpWebRequest was hardcoded to use IE 6 as a browser agent. Is there a way to programmatically determine which version of IE is installed on the server hosting the service?

It is currently hosted on a computer running Windows Server 2003 and can be installed on a computer running Windows Server 2008.

+4
source share
2 answers

you can also extract it from the WebBrowser control itself if you created it:

 WebBrowser browser = new WebBrowser(); Version ver = browser.Version; 

Warning: this must be called from the STA stream, otherwise it throws an exception. This can be seen in the MSTest code cleanup, which is an MTA, not an STA.

+2
source

It looks like the user agent can be installed: http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.useragent.aspx

I prefer the WebClient class these days, it is a wrapper for HttpWebRequest and allows you to do some things with less code: http://msdn.microsoft.com/en-us/library/system.net.webclient.aspx

0
source

All Articles