Block webpages and display error page

admin

Administrator
Staff member
I'm looking for a way to block some webpages on a computer. If the user visits, let's say, <a href="http://www.google.com/" rel="nofollow">http://www.google.com/</a>, then an error window will appear (I don't mind if the error is inside the browser or on a separate form). Some antiviruses/web protection softwares do <a href="https://www.google.it/url?sa=i&amp;...wOeWgCPF0-6bdYDXoQrg&amp;ust=1415032310349485" rel="nofollow">this</a>: please note that I'm interested only in blocking a little and specific number of pages.

I've already searched on the web for this. I found lots of examples, mostly about <strong>hosts</strong> file.
However, nothing on displaying an error page when the user goes into a "forbidden" page.

The code to edit the <strong>hosts</strong> file is this:

Code:
Dim s As String = My.Computer.FileSystem.ReadAllText("C:\Windows\system32\drivers\etc\hosts")
Dim finalFile As String = s &amp; VbCrLf &amp; "127.0.0.1    http://www.example.com/"
My.Computer.FileSystem.WriteAllText(finalFile, "z:\desktop\hosts")
My.Computer.FileSystem.DeleteFile("C:\Windows\system32\drivers\etc\hosts")
My.Computer.FileSystem.CopyFile("z:\desktop\hosts", "C:\Windows\system32\drivers\etc\hosts")

My application has administrator privileges to copy/delete system files.

I'm working with <strong>VB.NET WinForms</strong>, Visual Studio 2013.

Thanks,

<em>FWhite</em>