Changing "active content" security settings on WPF WebBrowser control - wpf

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.

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.

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

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

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.

Related

WebBrowser: How to automatically allow activeX content

I have a problem where I am opening a set of html files found on the local computer which use ActiveX controls.
The constant notification popup is frustrating as every page it appears.
I cannot change the file as it is generated by an external application and I do not want enable ActiveX controls for IE in general.
What I would like to do is allow my webbrowser control, embedded in a WPF window, to allow blocked content automatically if it is from the local computer (or at the very least any blocked content as I can control what my webbrowser control can and cannot open)
I cannot see any obvious way of doing this, there are no options to allow blocked content and no event for identifying when blocked contetn has been foud.
Is there any way to achieve this?
Thanks
EDIT -
There have been plenty of views for this question but not a single comment. I will welcome any suggestions, perhaps even an alternative control, I realise the default WebBrowser is not ideal. Are there any other browsers that do offer this feature?
To add a little detail to the problem I think I should explain the requirements some more:
The resource being displayed is a set of html files that are generated as a report by a legacy tool that cannot be changed.
The tool I have built will allow the user to define the destination for the report and then allow them to browse it using an embedded browser.
I really just need a control that will render html and ActiveX controls as a browser would but without any interference from internet security settings.
UPDATE - Unfortunately I am no longer working on this project, however I am interested in the problem/fix so I shal try and replicate it in my spare time.
I have also renamed the question as I realise the problem I am dealing with specifically is ActiveX content, which may have a solution (see answer from Rajesh) which is specific to this type of content.
You need to add the file location to your trusted sites. This is possible either with a webserver running on your local machine or if the folder where they are located is a shared folder.
In IE, go to Internet Options > Security, select "Trusted Sites" and click the "Sites" button. Enter the location (i.e. file:\server-Hostname\Sharedfolder* for a shared folder) and click "add" (make sure that the "Require server verification (https:)..." option is unchecked).
There is a lot more information available if you search "Add local file to trusted sites" on the web. I do seem to recall adding a local file location without having to share the folder, but at the moment I don't remember how I did it.
Simply add this line to your html page at the start before the html tag.
< saved from url=(0023)http://www.contoso.com/
and then select and comment it.

WPF user-editable config file

I'd like the users of my touch app to be able to modify certain UserControl properties by editing a text or XML file (e.g border colors and thicknesses, that sort of thing).
What's the best way to include a file like that in my project so that users can edit it after it's been published? I think if they go in the app.config file they're not editable?
app.config is editable, but should only be edited by an admin in the event that system settings change in a way that makes the deployment settings no longer applicable.
Prefer instead to used a settings file.
This seems to be the standard method of handling it.

Why Resource (.resx) file added on merely changing Form size and on adding button which is not resource

1- Resource files suppose to be added on adding some resource in application like image or audio or video etc. But if I just change size of form a .resx file incleded under that particular form. Changing size of form does not add any resource so why this .resx file?
2- I dropped a button on form and a resource file is included; again this button is not some kind of resource, it is object having its creation information in designer file?
3- A resource file added on dropping button on form but if I delete this resource file and run application it compile and run with NO error and button is still there. If this button has any relation with resource file then there must by some kind of compile or runtime error AND if .resx file has nothing to do with button then why it was added?
I am using VS 2008.
EDIT:
I have added a picture box and added an image in this now this is resource. i deleted the From1.resx file and I was expecting an error but NO ERROR AGAIN. In designer file picturebox referring image from properties folder which has Resources.resx file. Double click on this and image is there. SO WHAT WAS THE PURPOSE OF From1.resx FILE?
Thanks in advance for the help
AFAIK there isn't a strict requirement, but it is probably one of those things where it is simpler (read: less brittle, more predictable, cheaper to implement, whatever) to generate the resx if there is even the suggestion that one could possibly be required (even if it turns out to be trivial) than it is to fully track the nuances of when one is absolutely demanded.
I agree; in the scenario you describe no resx is required, but it isn't going to upset me.
(it still happens in VS2010, btw - but then I suspect you shouldn't hope for much change to winforms in VS2010)
It seems that the resx file for that form is most likely tied to localization. I.e. For localizing Text content such as the text on the button. When you add a resource such as an image file by default it is placed in the applications resx file that is located in the My Project folder. So if you have the form or projects language set I think that it will always create a local resx file for that form when you add a control that could be localized.

Why does the Image element give me a design-time error with "add as link"ed images?

I need to display an image, which I've done without problems before, but today I decided to be tricky and use "add as link" instead. Well, now I get:
The file Images/hello.png is not part of the project or its 'Build Action' property is not set to 'Resource'.
Wait... its Build Action is set to Resource. I've seen a Silverlight solution that involves the usage of Merged Dictionaries to share files between Silverlight and WPF projects, but it's not clear to me that this would even apply to my WPF + Image issue.
Has anyone solved this problem before? I could make copies of all of the images, but that seems a little silly if I have a shared repository with clip art and the like.
Dave,
I've just tried to add image as a link to plain WPF application. Build action is "Resource" (don't confuse with "Embedded Resource"). I've added it to the root, and refer to it as <Image Source="/file_name.jpg"/> - all works fine.
The message you have is it compile or runtime? If it's a runtime, how do you refer to the image? Do you see it in Reflector, when you open your assembly (it should be under Resources folder)?
I have images in one assembly which I want to share into another. I've used Add as Link in my second assembly. In the project where the actual image files are located they are in a Resources\Images folder. In the project which links to those files the links are also in a Resources\Images folder. At runtime a XamlParseException claiming "cannot locate resource" is thrown.
My xaml which is referencing the image is in a UserControls folder.
In the project which actually contains the images the path ..\Resources\Images\Blah.png works fine as expected.
Opening the DLLs in Reflector makes it obvious that in the assembly with the linked images holds the images at the root level - the compiler is not respecting the folder location. So in the project with the linked files I have to use ..\Blah.png to find the resource.
Surely a bug in the compiler?

silverlight wrappanel

_http://www.mscui.net/PatientJourneyDemonstrator/PrimaryCare.htm
I want to create/design the similar to above site/url using silverlight.
For this I have created separate user controls(Xaml files). Please advice me the steps/way to proceed in silveright. I am using silverlight versin 2.
I am thinking to use Wrappanel to adjust all the xmal files in Home page/default page. so that I can navigate to any page.
You can grab the XAP from your internet cache, open it with any zip tool and then use something like reflector to look in the DLLs to get the XAML out, should you desire to see how they did it themselves.
There's actually a project on codeplex which demonstrates how to do this dashpart effect with full source code called blacklight, so the above is probably not necessary.

Resources