I have a C#/WPF application that uses a WebBrowser control that presents a website as it's primary interface (for a kiosk). The website can call a C# method via javascript for some native processing. Everything works fine until I set the 'FEATURE_BROWSER_EMULATION' above IE7 (using the code below). When I do the javascript call to the native method does not get called unless I run the website from 'http://localhost' which works fine.
I'm assuming this is a security issue. I've messed with all of the security settings in IE (including setting the site as a 'Trusted Site'), but I can't seem to get it working.
Coding I'm using the set the emulation:
private void SetBrowserCompatibilityMode()
{
// http://msdn.microsoft.com/en-us/library/ee330720(v=vs.85).aspx
// FeatureControl settings are per-process
var fileName = System.IO.Path.GetFileName( Process.GetCurrentProcess().MainModule.FileName );
if ( String.Compare( fileName, "devenv.exe", true ) == 0 ) // make sure we're not running inside Visual Studio
return;
using ( var key = Registry.CurrentUser.CreateSubKey( @"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BROWSER_EMULATION",
RegistryKeyPermissionCheck.ReadWriteSubTree ) )
{
// Webpages containing standards-based !DOCTYPE directives are displayed in IE10 Standards mode.
UInt32 mode = 11000; // 11000 = IE11, 10000 = IE10, 9000 = IE9, 8000 = IE8, 7000 = IE7;
key.SetValue( fileName, mode, RegistryValueKind.DWord );
}
using ( var key = Registry.CurrentUser.CreateSubKey( @"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_ZONE_ELEVATION",
RegistryKeyPermissionCheck.ReadWriteSubTree ) )
{
// disable zone elevation prevention
UInt32 mode = 0;
key.SetValue( fileName, mode, RegistryValueKind.DWord );
}
using ( var key = Registry.CurrentUser.CreateSubKey( @"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_BLOCK_LMZ_SCRIPT",
RegistryKeyPermissionCheck.ReadWriteSubTree ) )
{
// enable <scripts> in local machine zone
UInt32 mode = 0;
key.SetValue( fileName, mode, RegistryValueKind.DWord );
}
using ( var key = Registry.CurrentUser.CreateSubKey( @"Software\Microsoft\Internet Explorer\Main\FeatureControl\FEATURE_NINPUT_LEGACYMODE",
RegistryKeyPermissionCheck.ReadWriteSubTree ) )
{
// disable Legacy Input Model
UInt32 mode = 0;
key.SetValue( fileName, mode, RegistryValueKind.DWord );
}
}