Restrict Users to use Compatible Browsers for your ASP .Net Application

Abhishek Mallick
Nov 8 · 3 min read

Well, web development is always interesting until you go live.

Now when you are getting your .Net Application ready you need to take care of many NFRs (Non-Functional Requirements). One of the NFRs is of compatibility with different browsers and versions.

Q. Why we need to do this?

A. Well an incompatible browser will always lead to broken features in your application as one or more libraries will run with errors thus the end-user will get distorted or uneven UI and you will get escalations.

As you can’t always control your end-users browser priorities and development for all types of browsers or versions is not an easy task.

Well, let me tell you what can be done to check this in a more scalable way (of course there are many other ways this is one suggestion and you are free to use it).

The technique I am going for will be using a Custom Action Filter from ASP .Net MVC. So let us start.

Let’s say you got your .Net application development going on and you want to work on browser restriction page, follow this:

1. Choose the output to show the user for incompatible browser

You can go from just a message saying:

“Your browser is incompatible. Please get a compatible browser”

to a UI design which has a UX that guides the end-user to which browsers your application is compatible with like:

Now the above page is coded simple enough to load in any browser or version

2. Code the output page with a controller action to it.

Now you have already designed your output screen, next is to code it out in HTML and bind it to a controller action.

Remember:

i. Make your HTML very simple

ii. Keep it compatible with all kind of browsers by least or no plugins like bootstrap etc.

iii. Test on all browsers before final use

3. Now let us create a filter.

Now we will work on the filter say “IncompatibleBrowser”.

To know how to work on the ASP.NET MVC Custom Action Filters please follow this tutorial.

What we will do in our filter:

a. We will create it in such a way that filters all the incoming request and watch for the browser agent version the request came from

b. Now we will be maintaining an XML file with the list of the browser agent version above which our application is compatible with

c. The filter will match the agent version from one in our list and thus decide whether the browser is compatible or not

d. If compatible then let the request pass otherwise show the error screen we created

For reference, please find my .net code for the custom action filter:

https://gist.github.com/abhi911kumar/5afa0d945dcb23e65e115b5f8c271f6d

Also, please find the XML file for custom action filter support:

https://gist.github.com/abhi911kumar/80c151e5d807bd809c97c26916062448

Now the above technique is scalable for the future and is a basic need for any UI development.

Abhishek Mallick

Written by

Solutions Architect, Researcher, Lead & Application/Web Developer. I architect, research, lead teams & build systems that scale @MultipleTechnology

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade