Block webpages and display error page


Staff member
I'm looking for a way to block some webpages on a computer. If the user visits, let's say, <a href="" rel="nofollow"></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=";...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:

Dim s As String = My.Computer.FileSystem.ReadAllText("C:\Windows\system32\drivers\etc\hosts")
Dim finalFile As String = s &amp; VbCrLf &amp; ""
My.Computer.FileSystem.WriteAllText(finalFile, "z:\desktop\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.