Web application not working in IE 10 - Asp.Net

Recently in the asp.net/sharepoint project I am working on, I got mails from client that the application is not working in Internet Explorer 10. Postbacks are not happening. Nothing is working in it. So I analysed the issue, and found that wow, YAMB (yet another microsoft bug :P). Here is the details about it and how to fix them...

Reason for the application not working in IE 10:
i) Asp.Net processes the “User Agent” string that is sent by Browser while requesting a page to determinate what are the capabilities of the Browser
    User Agent will be something like : Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; WOW64; Trident/6.0)

ii) Asp.Net has a set of configurations which maps User Agents with capabilities
<browser id="IE5to9" parentID="IE">
        <identification>
            <capability name="majorversion" match="^[5-9]" />
        </identification>
        <capabilities>
            <capability name="activexcontrols"     value="true" />
            <capability name="backgroundsounds"    value="true" />
            <capability name="cookies"             value="true" />
    These configuration are found in (depending on the framework version)
    C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG\Browsers

    These can be overridden/extended by application level confiruation in App_Browsers folder

iii) As seen in xml, Asp.Net uses Regular expression to identify the browser version from user agent, and it determines what capabilities are available in the browser.

iv) The given Regular Expression fails for IE 10. And this makes Asp.Net think that the Browser used is “Unknown” IE version, and hence returns false for many of the capabilities. (this also makes “Javascript” support to false)

v) Because of this, .Net doesn’t send the required Script files to browser. Hence while doing post backs, it tries to find a method __doPostBack which will not be available and the browser throws the below javascript error.
        SCRIPT5009: '__doPostBack' is undefined

Hot Fix for the Asp.Net issue:
    2.0 SP2 and 3.5 SP1 : http://support.microsoft.com/kb/2600100
    4.0 : http://support.microsoft.com/kb/2600088

Analysis details of the issue:
i) I was checking whether the issue is getting replicated in any dev servers so that I can apply the fix and see. It did not replicate in any of these servers

ii) Then I noticed that the issue is replicating in all but one of 5 UAT server

iii) So I took one working and one non-working server and tried to identify what is the difference between the two servers.

iv) So I checked what is the .Net version in the below configuration key of both the servers and they appeared the same.
        HKLM\Software\Microsoft\NET Framework Setup\NDP\

v) Then I checked the below things in both servers, and they all appeared the same.
    a) web.config in application
    b) *.browser in App_Browser folder
    c) Machine.Config
    d) Web.Config in Framework Config folder
    e) *.browser in Framework Config folder

vi) I tried creating a simple ASPX page and the issue is still coming in non-working server, but not in working server

vii) Upon further analysis I found that ASP.BrowserCapsFactory.dll will be created and installed in the assembly
    a) This dll is responsible for determining the Browser versions and the capabilities as illustrated above.
    b) This dll is generated based on the *.browser in Framework Config folder when we execute “aspnet_regbrowsers.exe /i”

viii) But this dll is not found in the assembly in both the servers. So I was wondering how it is working in differently in both the servers.

ix) Then I used ILSPY (open source alternative for Reflector) and checked the System.Web dll to see how things are working internally.

x) Then I found that there is a class called, BrowserCapabilitiesFactory in System.Web.Configuration namespace which is having the default Browser Capabiltiies and User Agent mapping
    a) This dll will be used by default when “ASP.BrowserCapsFactory.dll” is not found in assembly
    b) This class has hardcoded regular expression
    c) When I examined this dll in two servers, one dll has a updated RegExp to match IE 10 and future versions of IE. And this is the reason for difference in behaviors in working and non-working servers.
    d) Version of this DLL
        - In non working Server: 2.0.50727.4209
        - In working Server: 2.0.50727.4223

xi) Then I found that this System.Web dll is similar in Dev also. So I tried to replicate the IE 10 issue in Dev.
    a) So tried executing the “aspnet_regbrowsers.exe /i” command so that it generates the new ASP.BrowserCapsFactory.dll from *.brower files in Framework Directory (ie.browser file has the old regex in this machine). So I am expecting this to break application in IE10
    b) When I opened the Dev url I got some other message that says some browser configuration is missing.
        - More info on the error : http://support.microsoft.com/kb/2025676
        - I applied the resolution given in that article and it solved the issue.
    c) Then the IE 10 issue was also replicating.

Now Possible approaches to fix the problem:
i) Applying the Hot Fix for Framework. (will fix it for all applications in a server)

ii) Overriding the mapping, by creating a new .browser file in App_Browser folder (Will fix it for one application alone and I don’t recommend this)

iii) If we have the System.Web.dll with version that is found in working server we can fix this problem (provided if ASP.BrowserCapsFactory.dll is not available in assembly)
    a) It appears that the difference in the dll version is because the dll has come as a security update and not as a Framework update
        - 2.0.50727.4209 : http://support.microsoft.com/kb/2416470
        - 2.0.50727.4223 : http://support.microsoft.com/kb/2656362
    b) Since it is a security update, .Net version was the same in Registry.
    c) So it is possible to fix this issue by making this security update available but only if ASP.BrowserCapsFactory.dll is not available in assembly currently and it should not be generated later also.

iv) Until you fix it ask users to press F12 and change the Browser mode to IE 9.

v) But I recommend to ask users to use a better browser like FF or Chrome :)..... Never mind fixing it :P

Happy debugging

1 comments:

Anonymous said...

Cracking IELTS is a tough task visit kidsfront.com/competitive-exams/english-practice-test.html to enhance your chance to secure 2 grade higher.

Post a Comment