Welcome to Professional ASP.NET - Chris Love's Official Blog Sign in | Join | Help

Chris Love's Official ASP.NET Blog

Chris Love's Helpful tips, tricks and pragmatic development knowledge for the ASP.NET world.
Add to Technorati Favorites


ASP Insider Follow Me On Twitter
Blocking Unwanted Web Sites to Improve You Life

Back in March I posted a quick announcement about the release of Internet Explorer 8 and a common problem I was having at the time. I think I finally determined what the issue was, and it was not really Internet Explorer 8, but rather sites that were down. I am not sure I like the way IE handled the issue, but it did force me to figure out a real problem.

Today many web sites utilize contextual advertising for support. Google’s Adsense is the most popular service, but not the only one. There are hundreds available. These advertising services inject their ads through JavaScript/AJAX scripts. As I started interrogating the sites that seemed to fail they all seemed to have either custom advertising or obscure third party sources. It seems the servers their ads were originating would occasionally timeout, leaving IE to either hang trying to load a script or it would ultimately lead to the error displayed above.

So in my frustration I decided to start looking at the markup of the pages that would fail to load, then load upon making a 2nd request. I noticed these ‘off-color’ ad services. At the same time I had been poking around my home router and saw that I could block or black list urls in the router. For the record I have a NetGear router, the following figure shows an example of blocking sources of ads.

Once I did this, to an even deeper extreme than displayed above, the errors in IE went away. I honestly have not had any of those issues in a few months now.

Last month I discovered another method to block these potentially error prone sites and that is with a custom Hosts file on your system. My friend David Penton pointed me to a custom hosts file available designed to block all known ad sources. At this point I have not implemented this file on my laptop, primarily because I have sites I am working on that use contextual advertising and I need to ensure they are displaying.

A little background on what a Hosts file is or does. When a request is made for an address we typically do it using a domain name, not an IP. Ultimately this domain needs to be translated to an IP address so your computer knows where to send the request. This is typically done by calling a DNS server. I wrote about how domains are translated over a year ago if you need a primer on this process.

Every Windows computer has a Hosts file that is used as a local DNS server. In this file you can control where a domain resolves before it jumps to the whole DNS routine. The ad blocking Hosts file sets the IP for all these ad sources to 127.0.0.1, or your computer! This creates a local black lists that is going to be active not matter what network you are attached. This is a great idea, but at the same time you have to realize you are not going to see advertising, which sometimes can be useful to you. Plus this is how many sites are monetized and afford to stay online. So I do suggest going to this extreme with some caution. I am not personally offended by most advertising techniques and appreciate its place in our exchange of information, entertainment, etc. But sometimes it is excessive or just poorly implemented, which ultimately caused me to perceived IE issues.

You can customize the Hosts file, it is only text after all. The source file is also periodically updated as well, so when new sources appear your blacklist can get updated too.

Posted: Wednesday, June 03, 2009 8:03 AM

by Chris Love
Filed under:

Comments

Joel Ackerman said:

THANK YOU! THis has changed my life...IE8 is more sensitive than 7 and upgrading (well, changing) to it made these issues much more severe. I'm blocking a few sites in the router but implemented the entire host file in my primary pc and it's working out great so far.
# July 1, 2009 10:29 AM

Connie Gross said:

I have had the same problem with my laptop and it is driving me crazy. I have dealt with Netgear, Plum Choice and Microsoft and still have the same problem. I will try your suggestions and see how it does. Thanks for much.
# July 8, 2009 10:34 AM
Leave a Comment

(required) 

(required) 

(optional)

(required) 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS