I’ve encountered a strange problem: 2 identical client machines (WinXP/IE7) were connecting to a website (running on IIS6, ASP.NET 1.1 and employing some Infragistics controls – UltraWebGrid, WebTab, WebMenu). One machine showed a perfectly rendered page, while the other displayed page with missing images and styles and JavaScript functions behaved weirdly. Also, closer examination of HTML source of the page revealed that Infragistics controls rendered very different HTML between 2 machines. Mystery.
The only difference between 2 browsers I found was UserAgent string (For quick way to check your user agent go to http://whatsmyuseragent.com/). The first (working correctly) browser’s UserAgent was:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Active Content Browser; chromeframe; Active Content Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.4506.648; Active Content Browser; InfoPath.2)
The second (with incorrect rendering) was:
Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; Active Content Browser; chromeframe; Active Content Browser; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.0.4506.648; .NET CLR 3.5.30729; .NET CLR 3.5.2102; Active Content Browser; InfoPath.2)
The only difference is – the second UserAgent string has multiple entries for .NET 3.0.x and .NET 3.5.x. After doing a little research I found out that the culprit is the length of UserAgent string. If it’s over 260 characters – browser version reported incorrectly to the server. To test this I put together a very basic server-side browser detection code:
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load Response.Write("<B>Browser ::</B> " & Request.Browser.Browser & "<BR>") Response.Write("<B>Version ::</B> " & Request.Browser.Version & "<BR>") Response.Write("<B>Major::</B> " & Request.Browser.MajorVersion() & "<BR>") Response.Write("<B>Minor::</B> " & Request.Browser.MinorVersion() & "<BR>") End Sub
The results from the first (working) browser are:
Browser :: IE Version :: 6.0 Major:: 6 Minor:: 0
The results from the second (incorrect rendering) browser are:
Browser :: Unknown Version :: 0.0 Major:: 0 Minor:: 0
Bingo. Apparently this happens only for IE7 and below and only for ASP.NET 1.1. Server incorrectly detects browser version and Infragistics controls try to render HTML for a “down level” browser.
If you experience similar problems (one manifestation is that Silverlight applications like video player no longer work) – here is the solution.
Warning! Following steps involve Windows Registry editing. Use on your own risk.
UserAgent string doesn’t need every variations of major version of .NET framework and yet every time you install an update – a string with version gets added. Time to fire up Registry Editor. Run regedit.exe and open following key:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Internet Settings\5.0\User Agent\Post Platform
On the right side, notice multiple version of .NET framework (these screenshots are for reference only, your version may differ).
Leave only latest major versions 1.1.x, 2.0.x, 3.0.x, 3.5.x, 4.0.x and delete the rest.
This trims the UserAgent string and fixes the issue. You can go even further, having a .NET 3.5 SP1 means that you have .NET 2.0 installed as well, so if you have it, you can remove string with .NET 2.0 version as well
Find Qualitative research software here.