Prevent Clicking your AdSense by Accident in ASP.NET

13. February 2009

Here is a simple ASP.NET Code Snippet that Hides your AdSense by blocking or filtering your IP.

This part you would want to place before what you want to block the IP from:

<%

string strIP = Request.UserHostAddress;

switch (strIP) {

case "IP#1 here":

Response.Write("No Ad1: " + strIP + " ");

break;

case "IP#2 here":

Response.Write("No Ad2: " + strIP + " ");

break;
default:

%>

The following you place after whatever it is you want blocked from certain IPs:

Some Code here

<%

break;

}

%> 

Tags:

Reference , ,

Prevent Clicking your AdSense by Accident

6. February 2009

Here is a simple ASP Code Snippet that Hides your AdSense by blocking or filtering your IP.

This part you would want at the top of a page:
<%
dim blockip
 
blockip = Request.ServerVariables("REMOTE_HOST")
%>

The following you place wherever your Ads would be:

A Single IP# Version:


<%
 if blockip <> "000.000.000.000" then%>

    <div align="center">
“Your AdSense Code here.” Note: Replace the 000.000.000.000 and 111.111.111.111 with the IP# you wish to block.
    </div>
<%   
   else
   "Show Something Else."
   end if   
%>

 

A Two IP # Version:

<%
 if blockip <> "000.000.000.000" then
    if blockip <> "111.111.111.111" then %>
    
“Your AdSense Code here.” Note: Replace the 000.000.000.000 and 111.111.111.111 with the IP# you wish to block.
  
<%   
   else
      "Show Something at work."
   end if   
 else
     "Show Something at home."
 end if
%>

Tags:

Reference , ,