I have seen a couple of support calls recently that seem to center on various customer ASP.net websites that are not working well (or at all) with Internet Explorer 11. The issues are mostly centered on functionality available on the site's pages that works well in Internet Explorer 11 in compatibility mode or in other browsers, such as Chrome or Firefox, but not in IE 11 standard.
Through this blog post I will try to provide you with some basic things to check to make sure that your site is able to work well with IE 11 in standards mode. But first thing first: what happens when you switch from IE 11 standards mode to compatibility mode or inversely?
The browser changes the user agent string – which is a part of the request that is sent to the web server and which allows the web-server to identify the type of browser that is requesting a page when switching from compatibility mode to standards or inversely. The user agent is most useful when you are trying to adapt the way the site renders based on the browser that is used to view your web-application: the output for mobile is not the same as for desktop browsers, and might be different from older browsers like IE 6 – which people should not be using anymore – but in reality it is still there.
When you switch to compatibility mode in IE 11, the browser will send the user agent string of Internet Explorer 7, and will also use the Internet Explorer 7 rendering engine to try and render the output that comes back from your site. It might not be a good idea to try and switch your site to compatibility mode to get it to work with IE 11.
- ASP.net parsing of the user-agent string.
When IE 10 was the latest browser in town, there was a hotfix released by the ASP.net team to allow the .Net Runtime to correctly parse the IE 10 user agent, which was not the case. Before the fix, the IE 10 browser was not recognized as a javascript capable browser agent, which tends to break most ASP.net websites. Eric Law talks about the different flavors of this fix in the blog post below. It should be noted that the problem does not occur in ASP.net 4.5:
After you download and install the fix that corresponds to your version of ASP.net and the Windows operating system that is running on the machine that is hosting your website, you might still be wondering if your site will be able to recognize IE 11 correctly – and if you do not have install issues for the fix.
- ASP.net Browser Test Page
The fastest way to detect if the ASP.net Runtime is correctly able to detect and recognize IE 11, is to use the sample test page below. I have place the source code for the page below, you just need to copy and paste the code into a notepad file and save the file with an .aspx extension (such as BrowserTest.aspx).
<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Current browser</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Browser name is: <%= Request.Browser.Browser %>
</div>
</form>
</body>
</html>
I suggest you create a new website in IIS, so that you make sure that you are not inheriting settings that are set at the level of the website you will be hosting the page in. This will allow you to start with a clean configuration that inherits directly from the base settings for ASP.net defined by the .Net Runtime.
Place the page inside the site, and attempt to connect to the page using the Internet Explorer 11 browser. The page's code will just examine and print out the value of the Browser.Browser variable, which will contain the name of the browser used to request the page. This variable is populated by the ASP.net Runtime when the request reaches the server, after the query string has been inspected and parsed.
Should the output show a value of 'Mozilla' for IE 11 running in standards mode, then you have a problem with the installed fix – or you did not install the correct fix on your machine. Should you see an output value of 'InternetExplorer' the runtime is correctly able to detect the IE 11 browser running in standards mode.
- App_Browsers folder in your website
If you have passed the test of the webpage, but your site still does not work, the next thing to do is to move the test page in the root folder of your website. It is very likely that your website defines more settings than the default set defined by ASP.net. It is these settings which most likely break the parsing mechanism and do not allow your site to correctly detect the browser version.
If you see that the output of the test page when it runs in your website is 'Mozilla' when it was 'InternetExporer' in the test site, there are settings that apply only to your website that break the parsing mechanism of ASP.net which allows the detection of IE 11. These settings are most likely located in the App_Browsers folder: this folder contains .browser files which tell ASP.net how to parse user agents, settings which override the ones defined by ASP.net. If you find yourself in this case, you can try removing the .browser files from the App_Browsers folder and retry the test page: you will see that the output changes back to 'InternetExplorer' from 'Mozilla'.
- Remember IE is not InternetExplorer
Finally, you also need to check your site's logic. The browser parsing mechanism in ASP.net will show a browser name of 'IE' for Internet Explorer version and 10 and below. Starting with IE 11, the browser name parsed out by ASP.net will be 'InternetExplorer'. Hence if your site's logic tests if the browser name is equal to 'IE', then IE 11 will break your website's logic and you should change your site's code to allow for the new browser name.
Hopefully, this will allow you to iron out issues you see when using ASP.net and IE 11.
Paul Cociuba
www.linqto.me