Security Level for WebBrowser control

不打扰是莪最后的温柔 提交于 2019-12-19 03:09:48

问题


I am trying to migrate an .hta application to a C# executable. Of course, since it's an .hta the code is all HTML and Jscript, with calls to local ActiveX objects.

I created a C# executable project and am just using the WebBrowser control to display the HTML content. Simply renamed the .hta to an .html and took out the HTA declarations.

Everything works great, except that when I make calls to the ActiveX objects, I get a security popup warning of running an ActiveX control on the page.

I understand why this is happening since the WebBrowser control is essentially IE and uses the Internet Options security settings, but is there any way to get the WebBrowser control to bypass security popups, or a way to register the executable or DLLs as being trusted without having to change settings in Internet Options? Even a way to do on a deployment package would work as well.


回答1:


WebBrowser is an instance of Internet Explorer, and inherits security settings from IE.

One way could be to change the security settings defined in IE.

The other way could be to add a Custom Security Manager by implementing IInternetSecurityManager interface.

The WebBrowser Control or MSHTML hosts could create a security manager (by implementing the IInternetSecurityManager interface) that handles the URL actions and policies that are important to the host. Other URL actions and policies would be passed to the default security manager so it could handle them appropriately. The IInternetSecurityMgrSite interface would be used to handle Windows-related information from the component so that the customized security manager could handle any user interface it required. -



来源:https://stackoverflow.com/questions/2577386/security-level-for-webbrowser-control

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!