Click here to Skip to main content
15,122,149 members
Articles / Web Development / ASP.NET
Posted 19 Sep 2014


3 bookmarked

How your web site can determine if the user is running their IE browser in compatibility mode.

Rate me:
Please Sign up or sign in to vote.
1.86/5 (5 votes)
19 Sep 2014CPOL2 min read
This article show a quick way to determine if a user's IE browser is in compatibility mode.



As more websites are using HTML5 and 3rd party controls that use HTML5, we do not want a user’s browser using compatibility mode.  This article suggests one way you can determine if a browser is in compatibility mode.


The company I work for used to require IE users to put their browser in compatibility mode for our web site to render properly.  Then we moved to a newer version of .net and HTML5.  Now we want our users to no longer use compatibility mode.

The Problem

When users log into our website we want to provide a message that will let them know they have compatibility mode turned on in their IE browser.  The problem is: What is the easiest way to figure out if they have compatibility mode turned on?

The Solution

I spent a bit of time trying to find the best way to figure out if a browser is in compatibility mode.  When you google how to find a browser's compatibility mode you will find all sorts of solutions.  There is a JavaScript solution.  There is a solution where you look at the Request.UserAgent in your .net code.  As I looked through these options, they seemed more complicated and could possibly break as new versions of IE come out.  As I looked for a common thread I found that in any browser, as of this writing we are at IE11, when put into compatibility mode looks like IE7.  So here is my solution:

'check for compatibility mode
If Request.Browser IsNot Nothing AndAlso _
   Request.Browser.Browser = "IE" AndAlso _
   Request.Browser.Version = "7.0" Then
   'show error or do action
End If


//check for compatibility mode
if (Request.Browser != null && Request.Browser.Browser == "IE" && 
    Request.Browser.Version == "7.0") {
    //show error or do action

Of course the downside to this solution is that if someone is actually using IE7 they will see a message that tells them to turn off compatibility mode.  This is a risk I am willing to take.


This is a simple solution to determine in your website if a user is using compatibility mode.  If you need something more complicated there are more solutions out there.  I found this simple solution to work well for me.


First release.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Software Developer (Senior)
United States United States
I started my programmer career over 21 years ago doing COBOL and SAS on a MVS mainframe. It didn't take long for me to move into windows programming. I started my windows programming in Delphi (Pascal) with a Microsoft SQL server back end. I started working with when the beta 2 came out in 2001. After spending most of my programming life as a windows programmer I started to check out in 2004. I achieved my in April 2005. I have done a lot of MS SQL database stuff. I have a lot of experience with Window Service and Web services as well. I spent three years as a consultant programing in C#. I really enjoyed it and found the switch between and C# to be mostly syntax. In my current position I am programming in C# working on WPF and MSSql database stuff. Lately I have been using VS2015.

On a personal note I am a born again Christian, if anyone has any questions about what it means to have a right relationship with God or if you have questions about who Jesus Christ is, send me an e-mail. ben.kubicek[at]netzero[dot]com You need to replace the [at] with @ and [dot] with . for the email to work. My relationship with God gives purpose and meaning to my life.

Comments and Discussions

GeneralMy vote of 1 Pin
Jeremy Falcon19-Sep-14 11:46
professionalJeremy Falcon19-Sep-14 11:46 
GeneralRe: My vote of 1 Pin
kubben19-Sep-14 12:31
Memberkubben19-Sep-14 12:31 
GeneralRe: My vote of 1 Pin
Jeremy Falcon19-Sep-14 12:55
professionalJeremy Falcon19-Sep-14 12:55 
GeneralRe: My vote of 1 Pin
kubben19-Sep-14 13:23
Memberkubben19-Sep-14 13:23 
GeneralRe: My vote of 1 Pin
Jeremy Falcon19-Sep-14 13:38
professionalJeremy Falcon19-Sep-14 13:38 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.