Aousaf Rashid
Aousaf Rashid

Reputation: 5758

Disable wpf webbrowser security warning

I have a WebBrowser control in my app.It loads .mht files from apllicaions's current directory.However, i get a security warning saying : To help protect your security,your web browser has restricted this file from showing active content..I tried almost all the available solutions both on SO and msdn...I have tried this :

public void HideScriptErrors(WebBrowser wb, bool Hide)
{
     FieldInfo fiComWebBrowser = typeof(WebBrowser).GetField("_axIWebBrowser2", BindingFlags.Instance | BindingFlags.NonPublic);
     if (fiComWebBrowser == null) return;
     object objComWebBrowser = fiComWebBrowser.GetValue(wb);
     if (objComWebBrowser == null) return;
     objComWebBrowser.GetType().InvokeMember("Silent", BindingFlags.SetProperty, null, objComWebBrowser, 
     new object[] { Hide });
}

And called it in browser.Navigated event but with no result...Any help ?

Upvotes: 0

Views: 1150

Answers (1)

Jim W
Jim W

Reputation: 5026

That's because of system settings applicable to IE (and WebBrowser), one way to avoid it might be to host the mht file on the web.

EDIT:

We host our help in WebBrowser control, but to do it we distribute as HTML pages, and add this header to the top of every file

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

It's called the 'mark of the web', see Will The Mark of the Web always ensure IE runs local HTML file It prevents warnings, although it won't fix your issue with MHT, it's a suitable alternative.

Upvotes: 3

Related Questions