如何阻止一个网站编程方式使用DOTNET的 [英] How to block a website programatically using DotNet

查看:162
本文介绍了如何阻止一个网站编程方式使用DOTNET的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个Windows应用程序来使用DOTNET的窗户programming.I计算机阻止网站上找到了一些成果来阻止URL而不是一个网站。这是我必须阻止完整的网站不是一个单一的URL。

I am developing a windows application to block the websites from a computer using DotNet windows programming.I found some results to block an url but not for a website. That is I have to block complete website not a single url.

所以,可以有一个人帮助我解决这个问题。

So can some one help me to solve this problem

感谢你

Chaithanya

Chaithanya

推荐答案

这听起来像你想的System.Uri类的服务(的 http://msdn.microsoft.com/en-us/library/system.uri.aspx )。我猜,在某些时候,你必须决定你是否会允许或禁止基于URI的请求,在这种情况下,你会希望类似的逻辑如下:

It sounds like you want the services of the System.Uri class (http://msdn.microsoft.com/en-us/library/system.uri.aspx). I'm guessing that at some point you have to decide whether or not you are going to allow or disallow a request based on the URI, in which case you will want logic similar to the following:

Uri uri = new Uri("http://www.google.co.uk/somepage.html");
if (uri.Host.ToLower().EndsWith("google.co.uk"))
{
    // Do something
}

实验用类似的东西。需要注意的事项是:

Experiment with something like that. Things to note are that:

  • 如果您检查,看看是否主机等于www.google.co.uk,那么这仍然意味着其他子域(例如www3.google.co.uk)不会是阻止。
  • 如果您检查,看看是否主机包含google.co.uk,那么你就有可能阻止他人的子域包含(愚蠢的原因),别人的URL,例如google.co.uk.MyDomain.co.uk 这仍然是在一个有效的(如果愚蠢)的子域MyDomain.co.uk域。

这篇关于如何阻止一个网站编程方式使用DOTNET的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆