How to programmatically get ie10's REAL user agent
I need to programmatically get the User-Agent of my browser: IE10 on windows 7.
That should be an easy job. I tried navigator.userAgent in javascript and HtmlPage.BrowserInformation.UserAgent in Silverlight and both of them return:
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0E; InfoPath.3; .NET4.0C)
,which looks nice. However, as I noticed by Fiddler, the real UA IE10 is sending when browsing websites is:
Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)
,which is a shorter version. How can I get this shorter string that IE10 is using?
(I have Firefox 19 installed and Firefox doesn't have this problem, user-agents of two approaches are the same.)
Thanks,
Other applications have an opportunity to modify the User Agent to add the information you see above like the version of the .NET CLR, Media Center, etc... http://msdn.microsoft.com/en-us/library/ms537503(v=vs.85).aspx
Scott Hanselman had a post a while ago that some of this information comes from the Windows Registry http://www.hanselman.com/blog/TheNETFrameworkAndTheBrowsersUserAgentString.aspx
By the time you get to the browser the User Agent will have been updated to include whatever information is necessary, so you won't be able to get the original clean version unfortunately.
Typically you want to use feature detection over browser sniffing, but as you mentioned there are appropriate use cases for it. I know this doesn't answer the question as you were hoping, but hopefully it explains what is happening somewhat.
From what I can tell it is impossible to do the "feature detection" method to get the installed versions of the .NET Framework on the client. The userAgent string is the only way and that is broken.
链接地址: http://www.djcxy.com/p/51894.html上一篇: 代理标题到不同的子域