Snu*_*gus 21 c# ssl wcf iis-7.5
我有一个WCF服务页面只通过SSL运行WebGets/WebInvokes - 它在我的本地机器上工作正常(自签名证书).但是,在生产时,我可以访问service.svc(并且它向我提供有关如何使用的消息),但service.svc/AnyRequest返回404.两种环境都在IIS 7.5中托管.
我启用了跟踪,服务甚至没有获取任何方法请求(例如service.svc/SomeRequest),但它处理service.svc得很好.它也在听https://computername.domain.net/path/service.svc- 这是正常的吗?它通常应该指向https://publicfacing.com/path/service.svc吗?
另请注意,生产服务器在IIS中托管多个站点.
下面是我的web.config的system.serviceModel部分.从这里建议SSLBehave .
<system.serviceModel>
<bindings>
<webHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None"></transport>
</security>
</binding>
</webHttpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="SSLBehave">
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<add scheme="https" port="443"/>
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="UserManagement.ajaxAspNetAjaxBehavior">
<webHttp defaultOutgoingResponseFormat="Json" defaultBodyStyle="Wrapped" />
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"
multipleSiteBindingsEnabled="true" />
<services>
<service name="UserManagement.ajax" behaviorConfiguration="SSLBehave">
<endpoint address="" behaviorConfiguration="UserManagement.ajaxAspNetAjaxBehavior"
binding="webHttpBinding" bindingConfiguration="TransportSecurity" contract="UserManagement.ajax" />
</service>
</services>
</system.serviceModel>
Run Code Online (Sandbox Code Playgroud)
小智 13
我会从检查一些事情开始;
祝好运!
Dar*_*eal 13
每当我用新开发的WCF Web服务打404时,我要做的第一件事就是检查解释此类调用所需的处理程序映射,因为这通常是问题的原因。解决该问题的方法有多种,其中许多方法需要手动执行ServiceModelReg.execonsole命令:这些无疑是有效的过程,但如果您的开发机器具有特别复杂的配置,则可能不起作用-或产生其他问题。我下面提出的解决方法要稍长一些,但是具有可以更安全,更安全地解决问题的优点。
安装完成后,您应该能够运行WCF服务,而不会再次发生404错误。
有关此特定问题及其解决方法的其他信息,您也可以在我的博客上阅读此文章。
小智 6
我有同样的问题.根据我的阅读,默认情况下,WCF不是NT认证授权(或HTTPContext兼容).
我不得不将此添加到我的配置文件中的WCF服务web.config中的部分:
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
Run Code Online (Sandbox Code Playgroud)
你做了哪些,加上这个:
在实际的服务类定义中,我必须添加:
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class DataService : IDataDeliveryServiceContract
Run Code Online (Sandbox Code Playgroud)
这解决了我的问题.
您可以使用WsHttp绑定实现传输级安全性.看到这篇文章 ; 在您的绑定中尝试此替换:
<wsHttpBinding>
<binding name="TransportSecurity">
<security mode="Transport">
<transport clientCredentialType="None"/>
</security>
</binding>
</wsHttpBinding>
Run Code Online (Sandbox Code Playgroud)
文章提到你应该绑定绑定与端点.
小智 5
也许在你的RouteConfig.cs文件中添加以下行:
routes.IgnoreRoute("{resource}.svc/{*pathInfo}");
Run Code Online (Sandbox Code Playgroud)
只要您的.svc文件位于应用程序的根目录中.
| 归档时间: |
|
| 查看次数: |
41747 次 |
| 最近记录: |