vb.net - 仅在 HTTPS 上托管时出现 RESTful WCF 服务错误
问题描述
几年前,我关注了这篇RESTful WCF Services with No svc file 和 No config非常有用的文章,介绍了在不使用 svc 文件的情况下设置 RESTful WCF 并且工作得像个梦。但是最近我不得不将站点移到 HTTPS(仍然保留 HTTP 进行测试)并且一切正常,直到我删除了 HTTP 站点的绑定并且我收到一条错误消息,指向网络中的这个条目.config:
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
删除条目可修复错误,但会停止此设置提供的自动生成的帮助页面。
以下是引发的 2 个错误的简短片段:
异常:System.ServiceModel.ServiceActivationException:由于编译期间出现异常,无法激活服务“/myService”。异常消息是:找不到与绑定 WebHttpBinding 的端点的方案 http 匹配的基地址。注册的基地址方案是 [https].. ---> System.InvalidOperationException:找不到与绑定 WebHttpBinding 的端点的方案 http 匹配的基地址。注册的基地址方案是 [https]。
异常:System.ServiceModel.ServiceActivationException:由于编译期间出现异常,无法激活服务“/MyService”。异常消息是:在您的配置中检测到端点引用周期。必须删除以下引用循环:webHttpEndpoint/、webHttpEndpoint/。(...\web.config 第 222 行)。---> System.Configuration.ConfigurationErrorsException:在您的配置中检测到端点引用周期。必须删除以下引用循环:webHttpEndpoint/、webHttpEndpoint/。(...\web.config 第 222 行)
希望有人之前已经看到并解决了这个问题。
解决方案
想通了,所以我需要一个绑定,更新后的 web.config 是这样的:
<bindings>
<webHttpBinding>
<binding>
<security mode="Transport" />
</binding>
</webHttpBinding>
</bindings>
<standardEndpoints>
<webHttpEndpoint>
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true" />
</webHttpEndpoint>
</standardEndpoints>
推荐阅读
- java - 抽象类中的抽象属性
- javascript - 事件循环在 Javascript 中是如何工作的?
- javascript - 我的整个网站在响应模式下被推到左边如何找到问题?
- java - 在android studio中设置进度条的三个参数
- c# - 无法将 WinRT/C++ 组件加载到我的 UWP/C# 应用程序
- arrays - ARRAYFORMULA 兼容大小写敏感查找/索引匹配
- git - 如何克隆与分支具有相同文件夹名称的分支?
- java - 如何修复 Android Studio 中的 ''module java.base does not "opens java.io" to unnamed module '' 错误?
- r - 将类“perm.htest”对象从(多重排列 t 测试)转换为数据框
- node.js - 是否可以使用 Twilio whatsapp API 发送广播消息