改变“活动内容”。 WPF WebBrowser控件上的安全设置 [英] Changing "active content" security settings on WPF WebBrowser control

查看:155
本文介绍了改变“活动内容”。 WPF WebBrowser控件上的安全设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在整理一个WPF应用程序,一旦文件另存为.MHT或.HTML,它将允许用户通过WebBrowser控件查看PowerPoint文件。问题在于该文件包含ActiveX控件,默认情况下,每次加载这些文件时,WebBrowser控件都会默认显示警告,并说:为了保护您的安全,您的Web浏览器已限制此文件显示可访问您的活动内容。计算机。

I'm putting together a WPF application that will allow users to view PowerPoint files through the WebBrowser control, once the files have been saved as either .MHT or .HTML. The problem is that the files contain ActiveX controls, and the WebBrowser control by default will display a warning every time I load these files, saying "To help protect your security, your web browser has restricted this file from showing active content that could access your computer."

我在网上看到过很多地方谈论将每个页面上的Web标记,但是在这种情况下,这对我来说确实不起作用,因为内容作者可以控制文件,而不是开发人员,我不想告诉他们,他们必须在记事本中打开每个文件,并在每个文件中添加网络标记。

I've seen a few different places online talk about putting the mark of the web into each page, but that really doesn't work for me in this case, since the content authors have control over the files, not the developers, and I'd rather not tell them that they have to open every single file in Notepad and add the mark of the web to each one.

有什么方法可以只更改WebBrowser控件的设置以不显示该警告消息? IE具有类似的设置,但是它并没有延续到该控件中。

Is there any way to just change the WebBrowser control's settings to not display that warning message? IE has a similar setting, but it doesn't carry over into this control.

推荐答案

我们最终找到了一个不错的解决方案,尽管我仍然希望控件本身具有某种设置。要加载文档,只需将 browser.Source 设置为以下内容:

We eventually found a decent solution to this, although I still wish there were some sort of settings on the control itself. To load the documents, we just set browser.Source to be the following:

file://127.0。 0.1 / c $ / path / to / the / file(其中路径是不带C:\的绝对路径,例如c $ / Users / jschuster / mydocument.html)

file://127.0.0.1/c$/path/to/the/file (where the path is an absolute path without C:\, for example, c$/Users/jschuster/mydocument.html)

无论出于何种原因,控件都将以该格式显示URL引用的文件,而不会发出警告。

For whatever reason, the control will display files referenced by a URL in that format without a warning.

这篇关于改变“活动内容”。 WPF WebBrowser控件上的安全设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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