19

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.

4 Answers 4

17

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.

4
  • Wow... I love the so-called security of Internet Explorer, it's so easily tricked ;) Jun 12, 2009 at 12:38
  • Neither of these workarounds seem to work for me. Maybe it's windows 7 :(
    – SteveCav
    Aug 4, 2010 at 0:38
  • This worked for me, but on the first pageload after the application launched there would often be a significant lag.
    – Craig
    May 24, 2013 at 17:19
  • Does the 'c' in "c$" represents the C: drive? So if the HTML file is in D: drive, it would be d$ ?
    – Ignatius
    Dec 14, 2016 at 11:50
15

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
3
  • Never too old to post a suggested answer to legacy IE support! :)
    – Edza
    Jan 21, 2015 at 8:49
  • Setting js and css files to "Always copy" inside a Visual Studio .sln worked for me...finally.
    – whyoz
    Oct 22, 2015 at 18:34
  • I confirm that it works on Windows 10 with WebBrowser control loading HTML page which hosts Flash object. Solution with IP address and private share didn't work, though - main Flash movie was loaded but it failed to dynamically load content from ActionScript.
    – nrodic
    Dec 18, 2015 at 0:34
2

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 :)

1
  • Mostly because it adds a lot more work to our end, especially finding the end of the DOCTYPE declaration. I'm probably imagining it to be more work than it is, but right now we're just setting browser.Source to essentially a modified file path, so actually loading and parsing the file adds a bit more effort. Plus, it just seems like the WebBrowser control should have some sort of settings for this, in case the default security settings don't meet your needs. Jun 5, 2009 at 14:19
1

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.