How to disable password manager for WebBrowser control - wpf

The problem is simple, I don't want my embedded browser to display any modal dialogs. User enters the password on the site, that's it. No dialog to "remember this password".
Please DO NOT answer with "use different browser". My question is exactly about System.Windows.Controls.WebBrowser WPF control.
I KNOW that modifying the page HTML on the fly with autocomplete="off" works, but I wonder if there is a Windows Registry hack for that, as it's true for many other super annoying Internet Explorer quirks.

Heres a registry 'hack' for you:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Internet Settings
Add a new DWORD Value to this directory.
The name needs to be DisablePasswordCachingto and it must be a hexadecimal type.
Insert 1 as value and you should be good to go.
Now you have successfully disabled the password caching in IE (and WPF browser).
If this registry is set, then the standalone IE will not save any passwords too. It's a global option.
Links from where I got the solution:
SO (which is not a good answer so I wrote this one)
Microsoft Support

Related

Why is Visual Studio 2017's new AutoScale support resizing my Forms app at runtime?

We have a Windows Forms application used for testing our products that has had pretty much the same forms and dialogs for nearly 10 years now. AutoScaleMode in the designer is set to Font for both forms, and that hasn't changed since the original design. AutoSize is set to false and just for good measure (I guess) AutoSizeMode is set to GrowOnly. The following source lines are in Program.cs:
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Remember, this has been working flawlessly for years...
One of the recent updates to VS2017 included AutoScale support for monitors with different DPI. I have a relatively high DPI monitor, so when I made some changes to a Settings dialog (adding controls, etc) I started getting bright yellow banners cross the top of the designer surface telling me that AutoScaling was set to 125%, and would I like to change that? I tried going back and forth, and when in 100% mode (Autoscaling off) I was warned that XAML forms might not display correctly. Fine, I am working with Forms so I went back to "normal" scaling and the form looked fine.
Until I tried running the program. Now when I start the program the main form looks like this (details deleted to protect the guilty):
...but when I open the settings dialog it looks like this:
Yikes! It looks worse in practice, the relative images here don't do justice to the difference in size and scale.
I have no idea what got changed or how / why this is happening, but there's no way I can put this into production. I've tried changing the AutoScale settings, to no avail. Can somebody point me in the right direction here?
Thanks in advance!
EDIT: It seems the rescaling only happens on my machine when I run the app in Debug. Whatever is messing up the display of the forms on my machine doesn't do that on my associates' machines and isn't replicated to the executable produced by the build server.
On another note, I tried every DPI-related setting I could find, added those that weren't there due to the program's age, all to no avail. Nothing I have tried has had any effect on the program's display weirdness on my machine. Ugh.
I tried all the tricks I could find, short of disabling AutoScale completely, and nothing worked. I finally merged our develop branch in to my feature branch and inspected all 270 edits, choosing the oldest settings I could find for all size parameters, all controls. Ugh.
Along the way I stumbled across the following line in the Designer.cs file for the form:
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
This setting is NOT accessible from Visual Studio's designer, as far as I can tell, nor can I find anything about how or why it gets set. What I did find was that in the earlier version that did work as expected, the values were (8F, 17F) -- so I manually edited the line to match the older, working version. Success!
I also checked my Windows display settings, and the Custom Scaling value was at 100%, so I used the registry hack mentioned in one of the articles I found following the first link from the comment above (thanks, #Jimi) to disable auto-scaling in Visual Studio, then turned off the notification. Now I'm (finally) back in business.
Registry hack is here:
https://learn.microsoft.com/en-us/dotnet/framework/winforms/disable-dpi-awareness-visual-studio
If one uses the registry hack mentioned in the answer from DaveN59, and there is already entry for your ...\devenv.exe (mine was previously set to run as admin) then add the DPIUNAWARE string to the end of the "Data". Make sure to use a space as a separator.
Example: ^ RUNASADMIN DPIUNAWARE
I'm not sure what the ^ is for, but it was there and I just added DPIUNAWARE string. Also, if you just add this string, it will come up unscaled, but you will still see the yellow banner. To turn that off you'll need to select that option from with in Visual Studio. The instructions are in the link for the registry hack, also provided above. For conveinece here's the menu navigation path.
To disable notifications, choose Tools > Options to open the Options
dialog. Then, choose Windows Forms Designer > General, and set DPI
Scaling Notifications to False.

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.

Prevent script errors in web browser control WinForms

I've written a WinForms app to open a webbrowser control, and we use this to fill in a form to submit training course events programmatically from a database (it's not perfect, but it saves a lot of time - and no, the company concerned doesn't support XML feeds). However, the system has just started generating script errors, which prevent it working.
I've tried setting:
WebBrowser1.ScriptErrorsSuppressed = True
but this is only partly successful. The good news is that I don't get any script errors, but the bad news is that I can't then log on to the site.
Has anyone got any suggestions? As far as I'm aware the webbrowser control uses IE, so I can't get it to use another browser instead.
Thanks in advance!
According to the documentation http://msdn.microsoft.com/en-us/library/system.windows.forms.webbrowser.scripterrorssuppressed.aspx if you suppress the errors you also suppress dialog boxes. Meaning Alert Boxes/Authentication used to login will also be suppressed.
Below is what is noted in the documentation:
When ScriptErrorsSuppressed is set to true, the WebBrowser control hides all its dialog boxes that originate from the underlying ActiveX control, not just script errors. Occasionally you might need to suppress script errors while displaying dialog boxes such as those used for browser security settings and user login. In this case, set ScriptErrorsSuppressed to false and suppress script errors in a handler for the HtmlWindow.Error event.
As the documentation states, you can handle the HtmlWindow.Error event to allow dialog boxes, but only suppress scripting errors. (Although, I have been having issues with this actually working correctly.)

Gesture support for WPF WebBrowser Control which is displaying a HTML5 Site

In a standard WPF app, I have a WebBrowser control which has been navigated to a HTML5 sample page (http://ie.microsoft.com/testdrive/Browser/BrowserSurface/).
In the browser outside the app, I can interact with this site as expected – move photo’s around, use gestures etc.
In the WebBrowser control the site does not work as expected. It renders, but it does not respond to any touch gestures – It will, however, zoom in and out when I pinch.
Is it possible to make the WebBrowser control pass gesture events etc so that I can interact with the site as I would in a normal browser?
Many thanks for any help with this!
Kris
I know this is an old question but I think this has something to do with the fact that the WebBrowserControl standard uses IE7 ActiveX. I had the same problem which always gave me JavaScript errors in the control for TouchEvents.
After I added some registery key to force the WebBrowserControl to use the latest IE version installed it worked.
Here is what I've add to my registery. Paste it in a txt file and save it as an .reg file. Then DoubleClick it. Or enter the key/value manual in your registery via Regedit.
I even included this in my application code to add the key/value automaticially if it doesn't exist yet.
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION]
"RetailTestApplication.exe"=dword:270f
[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION]
"RetailTestApplication.exe"=dword:270f
Sorry, the code plugin srews up.
Change IE version for the WPF WebBrowserControl
MSDN Internet Feature Controls (B..C)

Can Silverlight HyperlinkButton forced to open page with Internet Explorer?

Can Silverlight HyperlinkButton forced to open page with Internet Explorer?
If someone has defaulted to one browser (let say Chrome), you cannot ask the current browser (using JavaScript) to open the link to a specific browser (i.e. you want Internet Explorer instead of Chrome). I am not sure about Flash or Silverlight's ability to do what you want.
I have found a technique but it is specific to VBScript inside Excel and it may need the UA agent check to make sure it works correctly for a target environment if you want to adapt the similar code in Silverlight:
http://www.mofeel.net/87-microsoft-public-excel/30085.aspx
With HyperLinkButton you can't. If your OOB app is in full trust mode you can use automation object InternetExplorer.Application to open and control IE.
If you have the right permissions in silverlight you can read and wright to disk. So yes you can.

Resources