- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我使用 C# 创建了一个 DLL,该 DLL 使用 WebRequest 来访问 WebService。这个 DLL 被声明为 ComVisible,所以我可以在 Delphi 中使用它。如果 WebRequest 未加密,则一切正常。但是当我使用 https 作为协议(protocol)时,我收到以下错误消息:
The underlying connection was closed: An unexpected error occurred on a send.
Unable to read data from the transport connection: Eine vorhandene Verbindung wurde vom Remotehost geschlossen.
但是当我从 .NET 应用程序中使用它时,相同的 DLL 仍然有效。
我创建了一个最小示例项目来查看错误是否可重现,我遇到了同样的问题。
这是webrequest的代码
[Guid("D0AAE68A-D2C0-4015-8DE6-471879267418"), ClassInterface(ClassInterfaceType.AutoDual), ProgId("WebRequestTest")]
[ComVisible(true)]
public class ComClient
{
public bool Authenticate(string customer)
{
var request = WebRequest.Create(@"https://server.azurewebsites.net/api/authenticate?apikey=xxxx&customer=" + customer);
request.Method = "GET";
try
{
using (var response = (HttpWebResponse)request.GetResponse())
{
using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
{
string responseString = streamReader.ReadToEnd();
Trace.WriteLine(responseString);
return true;
}
}
}
catch (Exception exc)
{
Trace.WriteLine(exc);
return false;
}
}
}
在delphi中代码也小而简单
procedure TForm1.btnTestClick(Sender: TObject);
var
client: TComClient;
begin
client := TComClient.Create(self);
if client.Authenticate('xxxxxxxx') then
Application.MessageBox('Ok', '', MB_OK + MB_ICONINFORMATION)
else
Application.MessageBox('Error', '', MB_OK + MB_ICONINFORMATION);
client.Free;
client := nil;
end;
为了使用纯 .NET 对此进行测试,我创建了一个小型单元测试,它可以正常运行。
[TestClass]
public class UnitTest1
{
[TestMethod]
public void TestMethod1()
{
ComClient client = new ComClient();
bool result = client.Authenticate("xxxxxxxx");
Assert.IsTrue(result);
}
}
在我看来,当从 COM 应用程序使用 .NET 程序集时,.NET 框架没有完全初始化。如前所述,如果我切换到 http 而不是 https,调用会正常工作。
最佳答案
我通过 Tav 的评论找到了解决方案。虽然 ServicePointManager.SecurityProtocol 包含协议(protocol) TLS | TLS11 | .NET 应用程序的 TLS12,只有协议(protocol) SSL3 和 TLS 被指定为 COM 应用程序。由于 Azure AppServices 默认配置为最低 TLS 版本为 1.2,因此您必须相应地重新配置 AppService 或在 COM 程序集中显式添加 TLS1.2。
ServicePointManager.SecurityProtocol |= SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;
关于c# - 通过 ComVisible DLL 访问 SSL 加密的 WebResource 失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54232260/
我发现对 WebResource.axd 的一个特定 Web 应用程序请求返回一个完全空白的页面。 (将链接复制并粘贴到新的浏览器窗口中会生成一个完全空的响应文档) IIS 日志显示对 WebReso
问题很简单:如何在 asp.net 应用程序中使用嵌入式资源?在程序集中包含资源的步骤是什么?如何引用它?可能会遇到哪些陷阱? 最佳答案 编辑:对于没有引用 Page 和 ClientScript 的
我有一个大型 .NET 2 Web 应用程序,它已更新为面向 .NET 4.0 框架。自更新以来,我发现我的日志中经常出现以下错误: This is an invalid webresource re
我时不时地在我的生产网站上发现这个问题,这让我非常困惑...... 我的应用程序在开发和生产中都能完美运行,但我时不时会收到一封来自全局错误处理的电子邮件,内容如下: 消息:这是一个无效的网络资源请求
我正在从事一个项目,我正在使用 ii7 中的 url rewite 模块实现一个友好的 url 系统。 一切都很好,效果很好。 我唯一的问题是 webresources.axd 和 Telerik.W
我需要使用 java test 向此其余函数发送 post 请求: @RequestMapping(value = "/upload", method = RequestMethod.POST) pu
在我们的内网环境中,网站运行良好,没有出现任何问题。从外部访问相同的地址,WebResource.axd 返回的末尾有以下结果: /* START */ /* Skipped loading 15
我有一个自定义控件,里面有一个网络资源。 webresource 是一个 javascript 文件,我将 javascript 文件上的构建选项设置为“嵌入式资源”,我的自定义控件所在的项目的 As
第一次来这里。我希望这个问题是有道理的: 我们有一个通用控件库,我正在尝试将其中的嵌入资源用于图像、JS 和 CSS。似乎每次部署到 TEST/PROD 时,都有一个 WebResource.axd
我正在寻找文件 WebResource.axd (查看其源代码)但我找不到它。 它在哪里? 最佳答案 .axd 文件通常作为 HTTP 处理程序实现。它们不作为 ASP.NET 网页存在,而是作为实现
这里是新手。我有一个如下所示的 REST 服务: @GET @PATH("/{id}/headerinfo") @Produces({ JSON, XML}) public Response getR
使用 WebResource.axd 时,您会看到在查询字符串中传递了两个参数。通常看起来像这样: WebResource.axd?d=9H3mkymBtDwEocEoKm-S4A2&t=634093
我是一个 crm 新手,所以请原谅我的误解或意外。 我正在尝试像这样使用 OrganizationServiceproxy 以编程方式创建早期绑定(bind)的网络资源(准确地说是 javascrip
我正在使用 maven-war-plugin 来过滤 WEB-INF 中的一些资源。主要是静态的东西,比如: var url = ${contextRoot}/save.json; 或 一切都很棒。
我在 ASP.NET Webform 元素中使用 WebResource 加载 .css 文件时遇到问题。该元素指的是 sharedProject 文件夹。元素中的每个页面都继承自 sharedPro
我在使用 blowery web 和 WebResource.axd 时遇到了麻烦。 什么是 WebResource.axd? 最佳答案 WebResource.axd 提供对项目内嵌入资源的访问。它
我正在处理创建 Jersey 客户端的任务。我正在使用 Jersey 1.18。目标 URL 如下所示。 https://api.test.com/test/{id}?param1=test1&par
我无法在我的网站上加载脚本文件。其他一切正常。但是,我还没有尝试过 ScriptResource.axd。 我已经验证了这个问题在 cassini 和 IIS7 上都存在。 我已经验证了我的 64 位
将 javascript 文件标记为“嵌入式资源” 向我的 AssemblyInfo 类添加了 WebResource 属性 现在我试图将嵌入的 javascript 输出到我的母版页。我得到的只是来
我从网络场中的一台 ASP 服务器收到大量错误警报,并且所有服务器的 web.config 文件中都具有相同的计算 secret 钥。我环顾四周,但没有找到这个确切案例的答案。欢迎任何建议。 感谢您考
我是一名优秀的程序员,十分优秀!