asp.net – 使用SSL无法找到wcf服务的资源
发布时间:2020-12-16 06:50:33 所属栏目:asp.Net 来源:网络整理
导读:我使用asp.net vb创建了一个REST api,我试图通过安全连接(https)调用api,但是我遇到了错误 The resource cannot be found 我可以使用(http)调用任何方法,但使用(https)我不能.我可以使用(https)访问api(service.svc)的主页但功能问题!!下面是我的配置和功能
我使用asp.net vb创建了一个REST api,我试图通过安全连接(https)调用api,但是我遇到了错误
The resource cannot be found 我可以使用(http)调用任何方法,但使用(https)我不能.我可以使用(https)访问api(service.svc)的主页但功能问题!!下面是我的配置和功能标题. <system.serviceModel> <services> <service name="RESTAPI" behaviorConfiguration="MyServiceTypeBehaviors"> <endpoint address="customBinding" binding="customBinding" bindingConfiguration="basicConfig" contract="RESTAPI"/> <endpoint address="" behaviorConfiguration="HerbalAPIAspNetAjaxBehavior" binding="webHttpBinding" contract="HerbalAPI" /> <endpoint contract="RESTAPI" binding="mexHttpBinding" address="mex" /> </service> </services> <!-- **** Services ****--> <behaviors> <serviceBehaviors> <behavior name="MyServiceTypeBehaviors"> <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> <serviceDebug includeExceptionDetailInFaults="true"/> </behavior> </serviceBehaviors> <endpointBehaviors> <behavior name="HerbalAPIAspNetAjaxBehavior"> <webHttp helpEnabled="true" /> </behavior> </endpointBehaviors> </behaviors> <bindings> <customBinding> <binding name="basicConfig"> <binaryMessageEncoding/> <httpTransport transferMode="Streamed" maxReceivedMessageSize="67108864"/> </binding> </customBinding> </bindings> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> API类 <ServiceContract(Namespace:="")> <AspNetCompatibilityRequirements(RequirementsMode:=AspNetCompatibilityRequirementsMode.Allowed)> Public Class RESTAPI <OperationContract()> <WebInvoke(Method:="GET",ResponseFormat:=WebMessageFormat.Json,RequestFormat:=WebMessageFormat.Json)> Public Function test(ByVal st As String) As JSONResultString //any code End Function End Class 解决方法
您需要在web.config文件中定义特殊绑定配置,以允许SVC服务正确绑定HTTPS请求.
请看一下这篇博文:https://weblogs.asp.net/srkirkland/wcf-bindings-needed-for-https 您的服务已经在web.config中定义,只需添加bindingConfiguration属性: <services> <service name="TestService"> <endpoint address="" behaviorConfiguration="TestServiceAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webBindingHttps" contract="TestService" /> </service> </services> 然后定义webHttpBinding的特殊绑定设置,因此修复HTTPS请求的神奇部分是< security mode =“Transport”/>: <bindings> <webHttpBinding> <binding name="webBindingHttps"> <security mode="Transport"> </security> </binding> </webHttpBinding> </bindings> 这将有效地将服务切换到HTTPS,但是如果要同时使用HTTP和HTTPS,则需要定义2个绑定配置,然后每个服务有2个相同的端点,其中一个使用http bindingConfiguration,另一个使用https bindingConfiguration如下: <bindings> <webHttpBinding> <binding name="webBindingHttps"> <security mode="Transport"> </security> </binding> <binding name="webBindingHttp"> <!-- Nothing special here --> </binding> </webHttpBinding> </bindings> <services> <service name="TestService"> <endpoint address="" behaviorConfiguration="TestServiceAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webBindingHttps" contract="TestService" /> <endpoint address="" behaviorConfiguration="TestServiceAspNetAjaxBehavior" binding="webHttpBinding" bindingConfiguration="webBindingHttp" contract="TestService" /> </service> </services> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – 使用字符串列表绑定GridView
- asp.net-mvc – DAL – > BLL < - GUI组合根.如何设置DI绑
- 使用Asp.Net进行异步编程的最佳方法
- (二)快速搭建 ASP.net core Web 应用
- asp.net – 单元测试Web服务 – HttpContext
- asp.net-core – 如何在ApplicationStarted事件中优雅地中止
- asp.net – Mono apache2 =服务暂时不可用(503)
- asp.net-mvc-4 – mvc 4捆绑和缩小 – 当我刷新时没有获得3
- asp.net-mvc – MVC – 重定向在构造函数内
- asp.net – 如何使用Inno Setup脚本创建IIS应用程序和应用程
推荐文章
站长推荐
- .net – 加密ApplicationServices ConnectionStr
- asp.net – 在IIS上部署MVC应用程序时,我收到一个
- asp.net – 微软azure smtp电子邮件中继设置
- asp.net-mvc – ASP.NET MVC – 从另一个项目引用
- 在Managed Code通过Google Gmail发送邮件以及如何
- asp.net – 我可以在SQL会话状态配置中重用现有连
- asp.net-mvc-3 – 使用Razor在Telerik MVC3网格中
- asp.net-mvc – 使用IoC,可以向Singleton注入具有
- asp.net 下载文件时根据MIME类型自动判断保存文件
- asp.net-mvc – 公共静态类数据对于ASp.net MVC中
热点阅读