Search code examples
c#ipblacklist

Check Ip Against Server Issue C#


So i have some code that will check if a user is on a ip blacklist list and this is the code i have come up with

string externalip = new WebClient().DownloadString("http://icanhazip.com");
bool checkipagainstserver = !new WebClient().DownloadString("https://ringarang.github.io/ipchecker.html").Contains(externalip);

then it is

if (checkagainstserver)

it shows a message box and quits the application

This code builds fine and works. If I change the url, it will catch out but when I add my ip to that list, it doesn't block execution and show message box even though my ip is clearly on that server text file

(the server files are there for testing and will be moved to the domain when done)


Solution

  • I fixed it the code needed too be

     string externalip = new WebClient().DownloadString("http://icanhazip.com");
     WebClient tempWebClient = new WebClient();
     bool checkipagainstserver = 
    

    then i needed to convert it