ASP.net 4.0 & IE 11 issues

A prime example of why Feature Detection should be used over Browser Detection

Windows, ASP.net

Microsoft, since the dawn of .net have, been using Browser Detection in ASP.net to decide what JavaScript should be included. With the release of Internet Explorer 11 ASP.net delivers special JavaScript that intended use is for IE <7 and breaks a number of websites!

With Christmas many people have got their hands on new Windows 8 Tablets / Laptops, all of which are shipped with Internet Explorer 11. Many of the people I know have complained that sites have stopped working, even some of my own, so today I had a look and found a KB update that needs to be applied.

Known Issues

There are a few issues that I've noticed, I'm sure there are more to come, which exhibit different error messages.

Missing the __doPostBack method

Now if you've done any work in ASP.net you'll have come across this method. It's called by many many core ASP.net controls almost everywhere a control triggers a PostBack to a server.

For example the following ASCX markup

<asp:linkbutton runat="server" 
               id="btnFoo" 
               onclick="btnFoo_Click"
               cssclass="btn btn-default">
    Click me!
</asp:linkbutton>

Would render a HTML Anchor with the following markup

<a id="ctl00_ctl00_btnFoo"
   href="javascript:__doPostBack('ctl00$ctl00$btnFoo', '')"
   class="btn btn-default">
    Click me!
</a>

Now, albeit in the past, I've called this function to trigger updates; I'd suggest if you're still doing this trigger a click of the link / button instead, it's more reliable.

Regardless, if you compare the source rendered by the server to IE11 vs, say, Chrome the entire script block, even the EVENTTARGET & EVENTARGUMENT form fields are missing.

Missing Sys.WebForms JavaScript Object

For me, it's a fundamental requirement to know when ASP.net page has either completed loading or an UpdatePanel has started/finsihed being updated. To achive this I use the Sys.WebForms object and attach the same event handlers to these events as have been attached to say $(document).ready

For example :

  Sys.WebForms
     .PageRequestManager
     .getInstance()
     .add_beginRequest( function () {
        // Pre XHR (AJAX) Request
     });

  Sys.WebForms
     .PageRequestManager
     .getInstance()
     .add_endRequest(function () { 
        // Completed XHR (AJAX) Request
     });

Because IE 11 has been identified incorrectly, as IE < 7 the server decides it's unable to preform XHR (AJAX) requests and excludes the script used to achive this, hence the entire PageRequestManager isn't avaliable.

The decision to exclude IE < 7 is kinda werid as Microsoft were the first to introduce XHR into their Browser, back in IE 5!!

Other Issues

I'm sure there are many other issues being caused, if you've found any please leave a comment below.

Nevertheless, if you're experiancing issues with IE11 compare the responses rx'd by IE11 and another browser, they should be the same and if they aren't then odds on you've been bitten by this Browser Dection Bug!

The Fix

A number of solutions have been suggested adding special App_Browser folders; Installing .net 4.5; Adding Meta tags to the <head> or HTTP Header. All of these either have flaws or not viable options.

I'm opting (not yet tested) to install this patch that Microsoft have relased KB2836939. This requires a server restart, so I'll be upading the production servers this evening.