Click here to Skip to main content
15,896,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using this code for blocking website. but it block website for all user. i want to block website for specific user not for all user.please suggest me how to do this. any links. suggestion etc.
I want to block website on system for user only not for all user. For example. There is two user in system e.g . Bob and Jimmy . i want to block "www.facebook.com for Bob. not for Jimmy. If Jimmy log in system he can access "www.facebook.com". but when Bob login he can not access. its a window application.......I am using the below code.but it block for all user

C#
String strpath = @"C:\Windows\System32\drivers\etc\hosts";
StreamWriter objstrWri = new StreamWriter(strpath , true);
String siteDtl= "\n 127.0.0.1 google.com";
objstrWri .Write(siteDtl);
objstrWri .Close();
Posted
Updated 12-Oct-12 1:13am
v3
Comments
Sushil Mate 12-Oct-12 6:59am    
can u explain more.. where & what exactly you want to do it? i mean Windows application/Web Application..
pradeep rasara 12-Oct-12 7:05am    
I want to block website on system for user only not for all user. For example. There is two user in system e.g . Bob and Jimmy . i want to block "www.facebook.com for Bob. not for Jimmy. If Jimmy log in system he can access "www.facebook.com". but when Bob login he can not access. its a window application.......
MT_ 12-Oct-12 7:55am    
You should use firewall for such purposes

1 solution

That's not at all a C# problem.

A possible solution is a proxy server, with user authentication. Then the proxy server can be configured in the desired way.

A simpler solution is a proxy configuration script, typically "proxy.pac". When the browser is configured to take that script from a user-specific location, you can get the desired effect.
The proxy.pac script looks something like
JavaScript
function FindProxyForURL(url, host)
{
    if (dnsDomainIs(host, ".facebook.com")) {
        return "PROXY 127.0.0.1:80";
    }
    else {
        return "DIRECT";
    }
}
 
Share this answer
 
Comments
fjdiewornncalwe 12-Oct-12 9:58am    
+5. Nice

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900