如何在C#中动态阻止网站? [英] How to block a website dynamically in C#?
本文介绍了如何在C#中动态阻止网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用C#编写的Windows Service动态地阻止某些URL。我不想通过写入hosts文件来做到这一点。
例如,我想拦截url http://示例。 (在所有的浏览器中),而且从上午7点到上午8点阻止
http://example.com/another
。
这是可能的,我该怎么办?
最好的问候,
Andrew
解决方案
您可以使用 Windows防火墙API 。请参阅文章 托管类来查看/操作Windows防火墙 ,John Cole。
I would like to block certain URLs dynamically from Windows Service written in C#. I don't want to do this by writing to hosts file.
For example I would like to block the url http://example.com
(in all browsers), but also block http://example.com/another
from 7 to 8 am.
Is this possible, what should I do?
Best regards, Andrew
解决方案
You might be able to use the Windows Firewall API. See the article, Managed classes to view/manipulate the Windows Firewall, by John Cole.
这篇关于如何在C#中动态阻止网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文