HTTP_USER_AGENT and navigator.userAgent is not the same, any idea?

I use Javascript in the client, get navigator.userAgent , returns:

 Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0; .NET CLR 2.0.50727; SLCC2; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; HPNTDF; .NET4.0C; .NET4.0E) 

use C # Request.ServerVariables["HTTP_USER_AGENT"] , returns:

 Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; Win64; x64; Trident/5.0) 

As you can see, its IE: (.

IE always does this, or just me? How to get the same value?

PS , I tried this even in local IIS, the same results

+4
source share
1 answer

The user agent string in Internet Explorer nine and above will almost always differ between the version of sending the HTTP request and the one received using navigator.userAgent . This is due to the so-called object tokens in the string. The background for this is explained here: http://msdn.microsoft.com/en-us/library/ms537503%28v=vs.85%29.aspx

From the msdn document:

Earlier versions of Internet Explorer included feature markers defined by the Pre-Platform and Post-Platform that are part of the user agent string during the HTTP negotiation process. Over time, this leads to excessively long user agent strings, which in turn creates problems for specific web servers. Problems typically occurred when user agent strings were longer than 256 characters. Starting with Internet Explorer 9, the user-agent string no longer includes function tokens during HTTP negotiation. Function signs are included in the value returned by the userAgent property of the navigator object. Applications that rely on earlier behavior should be modified accordingly.

You must decide what you want to use in your application. Unable to โ€œsyncโ€ them. The one received through Javascript should contain more information ...

+1
source

Source: https://habr.com/ru/post/1394288/


All Articles