简体   繁体   English

是否可以将ServicePointManager与Webbrowser控件一起使用?

[英]Is it possible to use ServicePointManager with Webbrowser control?

I want to disable "Alert window" that I get from login page of one HTTPS site with "untrusted certificate". 我想禁用“警报窗口”,我从一个HTTPS站点的登录页面获取“不受信任的证书”。

ServicePointManager is used for WebRequest/WebResponse: ServicePointManager用于WebRequest / WebResponse:

 > public static bool > ValidateServerCertificate(object > sender, X509Certificate certificate, > X509Chain chain, SslPolicyErrors > sslPolicyErrors) { > return true; } > > ServicePointManager.ServerCertificateValidationCallback > = new RemoteCertificateValidationCallback(ValidateServerCertificate); 

but how can I use it with Webbrowser control? 但是如何在Webbrowser控件中使用它?

The ServicePointManager is for managed code; ServicePointManager用于托管代码; WebBrowser is a wrapper around shdocvw, so will almost certainly have a very different programming model. WebBrowser是shdocvw的包装器,所以几乎肯定会有一个非常不同的编程模型。

if you can automate this (and I'm not sure that you can), I would expect to have to reference the COM version to get the full API (see: AxWebBrowser). 如果您可以自动执行此操作(我不确定您是否可以),我希望必须引用COM版本才能获得完整的API(请参阅:AxWebBrowser)。 WebBrowser only exposes a .NET-friendly subset of the full functionality - enough to get most common jobs done. WebBrowser只公开一个.NET友好的完整功能子集 - 足以完成最常见的工作。

One other option might be to get the data yourself (WebClient / WebRequest / etc), and simply push that html into the WebBrowser - but this will mess up external links etc. 另一个选择可能是自己获取数据(WebClient / WebRequest / etc),只需将该html推送到WebBrowser中 - 但这会搞乱外部链接等。

As noted by Marc Gravell, I don't believe that it is possible to use ServicePointManager or ServicePoint classes in the WebBrowser Control, nor do you need to though. 正如Marc Gravell所说,我不相信可以在WebBrowser控件中使用ServicePointManager或ServicePoint类,但您也不需要。

See my answer to your other post where you asked your original question. 在您提出原始问题时,请查看您对其他帖子的回答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM