C#隐藏WCF隐藏未找到端点响应
我正在尽可能多地隐藏我的WCF。如果有人输入我的WCF的url,则会显示响应“Endpoint not found”。如果他们尝试get请求,则会显示方法not allowed,因为我的服务只接受post请求 我的web.config中已经包含以下内容C#隐藏WCF隐藏未找到端点响应,c#,wcf,hide,C#,Wcf,Hide,我正在尽可能多地隐藏我的WCF。如果有人输入我的WCF的url,则会显示响应“Endpoint not found”。如果他们尝试get请求,则会显示方法not allowed,因为我的服务只接受post请求 我的web.config中已经包含以下内容 <behaviors> <endpointBehaviors> <behavior name="webBehavior"> <webHttp hel
<behaviors>
<endpointBehaviors>
<behavior name="webBehavior">
<webHttp helpEnabled="false" />
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="Default">
<serviceDebug includeExceptionDetailInFaults="False" />
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
</behavior>
</serviceBehaviors>
</behaviors>
我不想显示任何响应,除非他们有确切的url和确切的post参数。我不确定是否需要更改我的“自定义错误部分”。我的理解是,自定义错误仅适用于引发异常的情况。找不到终结点,不允许的方法不是异常
任何帮助或建议都将不胜感激。我建议与IDispatchMessageInspector或IDispatchPerationSelector一起实施iSeries行为或IEnpointBehavior。通过这种方式,当收到请求时,您可以编写代码来进行自定义响应 我没有一个完全符合您需要的示例,但是您可以看看下面的文章,在这篇文章中,我修改了传出消息上的XML名称空间标记。我的想法是,如果请求不符合您的标准,您可以简单地返回null或404。还包括一些有关该主题的MSDN文章 阅读本文 如果要抛出404,可以从OperationSelector中抛出,如下所示:
...
throw new System.ServiceModel.Web.WebFaultException(System.Net.HttpStatusCode.NotFound);
...