AuthorQuestion
How to block a Website using C#
Posted on: 09 Oct 2009
Hai
 I am developing an C# application(not asp.net) in which I have to get the urls typed by the user in the browser and I have to compare the urls with a set of urls and decide whether to allow or to deny the user to navigate to the website.
I have tried with appending to C:\windows\system32\drivers\etc\hosts file but its not working.So Is there any way I can do this?How to block the sites by getting the urls.Can someone suggest me how to approach to the solution with some sites or code that can help me.

Thank You
Chaithu 

[ + ]
AuthorReply
Re: How to block a Website using C#
Posted on: 10 Oct 2009  

you can use the webpermission class or webbrowserpermission class you can use them either declarative way using attribute or imperative way by incorporating them in the code




I will never die, I always reborn again and again. Be the matrix with me. Amen
                                                     
Re: How to block a Website using C#
Posted on: 10 Oct 2009  
Take a look at Routing and Remote Access Service APIs in the Platform SDK. You will have to PInvoke functions to build a firewall of sorts (that filters packets).
 
You also can check the following code:
 
String path = @"C:\Windows\System32\drivers\etc\hosts";
StreamWriter sw = new StreamWriter(path, true);
String sitetoblock = "\n 127.0.0.1 google.com";
sw.Write(sitetoblock);
sw.Close();

Regards,
Niradhip(James Hetfield)
MCP,MVC,MVP(Mindcracker)
--------------------------------------------------------------------------------------
Please remember to click “Do you like this answer” on the post that helps you.
Re: How to block a Website using C#
Posted on: 12 Oct 2009  
But I have tried with hosts file but if I block www.google.com,and if I type www.google.co.in it allows me to browser to acess google.I need to block entire google.How can I do this?

Thank You
chaithu

SPONSORED BY
  • PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.