使用 System.Net.WebClient 下载时指定自定义 DNS 服务器
我正在尝试通过在从 OpenDNS 退回请求的同时尝试浏览提交的网站来过滤它们。如果收到的页面是 OpenDNS 页面,我会假设该页面应该被阻止。
我如何使用 System.Net.WebClient 类完成此任务?
I'm trying to filter submitted web sites by attempting to browse them while bouncing the request off of OpenDNS. If the page received is the OpenDNS page, I'll assume the page shoudld be blocked.
How might I accomplish this task using the System.Net.WebClient class?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
WebClient
类依赖于Dns
类,该类调用系统并使用当前配置的 DNS 设置。如果您沿着这条路线走下去,唯一的方法就是首先更改 DNS 设置,这可能不适合您。相反,要么查看第三方控件,如 DnDns (免费、开源),要么直接调用 < code>nslookup 并将结果解析为 详细信息。
The
WebClient
class relies on theDns
class which calls into the system and uses the currently configured DNS settings. If you go down this route the only way to do what you want is to change the DNS settings first which is probably not an option for you.Instead, either take a look at a thrid-party control like DnDns (free, open source) or just call
nslookup
and parse the results as detailed here.