Jonathan Schuster
Jonathan Schuster

Reputation: 2390

Changing "active content" security settings on WPF WebBrowser control

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."

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.

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.

Upvotes: 19

Views: 13650

Answers (5)

Enigma
Enigma

Reputation: 61

the solution from here worked for me on windows 11

the solution is to put the line below at the beginning of the html file you want to load:

<!-- saved from url=(0014)about:internet -->

Upvotes: 0

vidriduch
vidriduch

Reputation: 4863

Hope this might help someone even that the question is a bit old ...

As per the link to "The Mark Of The Web" , adding comment like

<!-- saved from url=(0016)http://localhost -->

just under the HTML tag worked.

My index.html is in HTML folder, added as "content" set to "Always copy" in WPF project using WebBrowser control. The address to the file during execution look like this:

file:///E:/SRC_2013/WebBrowserTestApp/WebBrowserTestApp/bin/Debug/HTML/index.html

Upvotes: 15

Edd
Edd

Reputation: 701

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)

This worked for me as well on Win7.

Upvotes: 1

Jonathan Schuster
Jonathan Schuster

Reputation: 2390

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 (where the path is an absolute path without C:\, for example, c$/Users/jschuster/mydocument.html)

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

Upvotes: 17

Thomas Levesque
Thomas Levesque

Reputation: 292695

Why not insert the MOTW dynamically at the beginning of the file when you load it ?

By the way, thanks for your question : I didn't know about the "mark of the web" and it solved a problem I had :)

Upvotes: 2

Related Questions