Compatibility.png
Introduction
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.
Background
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:
If Request.Browser IsNot Nothing AndAlso _
Request.Browser.Browser = "IE" AndAlso _
Request.Browser.Version = "7.0" Then
End If
if (Request.Browser != null && Request.Browser.Browser == "IE" &&
Request.Browser.Version == "7.0") {
}
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.
Conclusion
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.
History
First release.
I started my programmer career over 26 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 vb.net when the beta 2 came out in 2001. After spending most of my programming life as a windows programmer I started to check out asp.net in 2004. I achieved my MCSD.net 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 vb.net 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 VS2019.
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.