以编程方式将受信任的站点添加到 Internet Explorer
我正在使用 WatiN 做一个 IE 自动化项目。
单击要下载的文件时,我会在 Internet Explorer 信息栏中看到以下内容:
为了帮助保护您的安全, Internet Explorer 已阻止此操作 网站向您下载文件 计算机。
为了下载报告,我可以手动将该站点添加到 Internet Explorer 的受信任站点列表中,但我更愿意在 .NET 中以编程方式检查该站点是否可信,如果不可信,则将其添加到列表中。
仅供参考,我目前使用的是 IE7。
I'm doing an IE automation project using WatiN.
When a file to be downloaded is clicked, I get the following in the Internet Explorer Information bar:
To help protect your security,
Internet Explorer has blocked this
site from downloading files to you
computer.
In order to download the report, I can manually add the site to Internet Explorer's list of trusted sites, but I would prefer to check programmatically in .NET to see if the site is trusted and add it to the list if it is not.
FYI, I'm currently using IE7.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(7)
看看这个
基本上看起来好像所有您要做的就是在
名为“http”的 REG_DWORD 值中创建注册表项,其值==2
Have a look at this
Basically it looks as if all you have to do is create registry key in
then a REG_DWORD value named "http" with value==2
下面是我为在 .NET 中编写注册表项而提出的实现。
谢谢你给我指明了正确的方向,本。
Here's the implementation that I came up with for writing the registry keys in .NET.
Thanks for setting me in the right direction, Ben.
很高兴看到你的帖子。 我唯一可以添加到已经做出的出色贡献中的是,只要 URI 包含 IP 地址(即该地址不是完全限定的域名),就会使用不同的注册表项。
在这种情况下,您必须使用替代方法:
假设我希望将 IP 地址添加到受信任的站点:比如说 10.0.1.13,我不在乎什么协议。
Glad I came across your postings. The only thing I can add to the excellent contributions already is that a different registry key is used whenever the URI contains an IP address i.e. the address isn't a fully qualified domain name.
In this instance you have to use an alternative approach:
Imagine I wish to add an IP address to the trusted sites: say 10.0.1.13 and I don't care what protocol.
使用 powershell 非常简单。
Using powershell it is quite easy.
除了将域添加到受信任的站点列表之外,您可能还需要更改设置“自动提示文件下载” ” 对于受信任的站点区域。 要以编程方式执行此操作,您可以修改键/值:
将值从 3(禁用)更改为 0(启用)。 下面是一些用于执行此操作的 C# 代码:
In addition to adding the domain to the Trusted Sites list, you may also need to change the setting "Automatically prompt for file downloads" for the Trusted Sites zone. To do so programatically, you modify the key/value:
Change the value from 3 (Disable) to 0 (Enable). Here's some C# code to do that:
下面是以编程方式向 IE 添加受信任站点的实现 - 基于 Even Mien 的代码。 它还支持域名和IP地址。 限制是无法定义特定协议,而是简单地对所有协议使用“*”。
Here is the implementation of adding trusted sites programmatically to IE - based on Even Mien's code. It supports domain name and IP address as well. The limitation is no specific protocol could be defined, instead it simply uses "*" for all protocols.
我不太同意 - 只要浏览器请求用户许可,站点将自身添加到受信任站点的能力就可以极大地简化用户体验,用户信任该域并且想要正确的页面显示。
另一种方法是用户必须手动进入互联网选项来添加域,这对于我的用户来说是不可行的。
我正在寻找一种 php 或 javascript 方法来让网站添加自身,可以通过一些 IE api,也可以通过注册表,正如您上面所解释的那样!
到目前为止已经找到了这些可能的解决方案:
I don't quite agree- as long as the browser asks the user for permission, the ability of a site to add itself to trusted sites can greatly simplify the user experience, where the user trusts the domain and wants correct page display.
The alternative is the user must manually go into internet options to add the domain, which is, for my users, not viable.
i'm looking for a php or javascript method for the site to add itself, either through some IE api, or through the registry as you've so helpfully explained above!
have found these possible solutions so far: