Custom IInternetSecurityManager not being called with dialogs(自定义 IInternetSecurityManager 未通过对话框调用)
问题描述
您好,感谢您的关注.
问题描述:
我已经实现了一个嵌入了浏览器控件的 c# WinForm 应用程序,并实现了 IInternetSecurityManager 来执行我们需要的任务,以便允许在 iframe 中使用我们本地安装的网页进行跨域访问.
I have implemented a c# WinForm application with the browser control embedded and have implemented IInternetSecurityManager to perform the tasks we need in order to allow cross-domain access in iframes with our locally installed web pages.
使用 IInternetSecurityManager、IOleClientSite、IDocHostShowUI 和 IDocHostUIHandler,一切都按预期工作.换句话说,我们的所有实现都被浏览器控件调用.
All things are working as expected with IInternetSecurityManager, IOleClientSite, IDocHostShowUI and IDocHostUIHandler. In other words, we are being called by the browser control for all of our implementations.
问题是当浏览器控件中加载的网页具有调用 window.showModalDialog() 的脚本时:正在使用的浏览器控件实例不再与我们的客户端站点通信.在上述任何接口中绝对不会调用任何 QueryInterface 调用或任何其他方法.
The problem is when the web page loaded in the browser control has script that calls window.showModalDialog(): The browser control instance that is being used no longer communicates with our client site. Absolutely no QueryInterface calls or any other methods are called in any of the interfaces mentioned above.
我假设对话框中的文档没有使用我们的安全管理器实现,因为 IE 显示的对话框中的 Web 浏览器控件与我们调用 SetClientSite() 的控件不同.
The document in the dialog is not using our security manager implementation I am assuming because the web browser control in the dialog that IE displays is not the same one we called SetClientSite() on.
问题:
我们如何与这个新的浏览器控件对话?我们需要能够在 IE(我们的 IInternetSecurityManager 实现)显示的对话框中赋予浏览器控制权.但是,我们从来没有机会告诉它我们的客户网站来进行连接,可以这么说.换句话说,没有来自 IE 的通信通过一个界面告诉我们,我是一个由 IE 创建的新浏览器控件,这是我的 IUnknown 界面.这是您设置我的客户端站点等的机会."如果 IE 有这样的通知,我们会很高兴.
How do we talk to this new browser control? We need to be able to give the browser control in the dialog that is shown by IE, our IInternetSecurityManager implementation. But, we never get the opportunity to tell it about our client site to make the hook up, so to speak. In other words, there is no communication from IE that tells us via an interface that says, "I am a new browser control created by IE and here is my IUnknown interface. This your chance to set my client site, etc." We would be golden if there was such a notification coming from IE.
结果是使用了两个不同的安全上下文,并且每当我们在使用 iframe 的对话框中时,我们的应用程序都会失败,因为我们的 IInternetSecurityManager 实现未在使用中.
The result is two different security contexts are being used and our applicaiton fails any time we are in a dialog using an iframe, because our IInternetSecurityManager implementation is not in use.
示例源代码:
我已经对源代码进行了精心设计以保护无辜者 :) 并简化为我认为您可以在其自己的 Visual Studio 2010 解决方案中使用的东西.
I have chiseled away at source code to protect the innocent :) and have reduced down to something I think you can work with in its own Visual Studio 2010 solution.
请阅读 ReadMe.txt 文件以获取有关问题、重现步骤等的信息.
Please read the ReadMe.txt file for information on the problem, repro steps, etc.
我编写的测试网页显示了指导您使用示例的信息和步骤.
The test web pages I wrote display information and steps to guide you through the use of the sample.
如果您对我要完成的任务有任何疑问或示例不够清晰,请告诉我.
Please let me know if you have questions about what I am trying to accomplish or if the sample isn’t clear enough.
请指教.谢谢.
http://home.comcast.net/~lowrider2112/bin/TestIEHost.rar
推荐答案
你可以重写网页浏览器的控制方法CreateWebBrowserSiteBase
.
You can override the web-browser's control method CreateWebBrowserSiteBase
.
protected override WebBrowserSiteBase CreateWebBrowserSiteBase()
{
return new ExtendedWebBrowserSite(this);
}
并像这样实现 ExtendedWebBrowserSite
:
class ExtendedWebBrowserSite : WebBrowser.WebBrowserSite,
IDocHostShowUI,
IfacesEnumsStructsClasses.IServiceProvider,
IInternetSecurityManager
...
可以调用类IInternetSecurityManager
.
这篇关于自定义 IInternetSecurityManager 未通过对话框调用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:自定义 IInternetSecurityManager 未通过对话框调用
基础教程推荐
- 如何激活MC67中的红灯 2022-01-01
- 有没有办法忽略 2GB 文件上传的 maxRequestLength 限制? 2022-01-01
- 将 Office 安装到 Windows 容器 (servercore:ltsc2019) 失败,错误代码为 17002 2022-01-01
- c# Math.Sqrt 实现 2022-01-01
- rabbitmq 的 REST API 2022-01-01
- SSE 浮点算术是否可重现? 2022-01-01
- 为什么Flurl.Http DownloadFileAsync/Http客户端GetAsync需要 2022-09-30
- MS Visual Studio .NET 的替代品 2022-01-01
- 将 XML 转换为通用列表 2022-01-01
- 如何在 IDE 中获取 Xamarin Studio C# 输出? 2022-01-01