如何向wcf-odata服务添加ipfilter



如何向oData WCF服务添加IP筛选器?

我发现一些博客文章解释了如何在web.config中添加额外的配置,但我在web.config(关于服务)中没有任何内容。

我遵循了Hanselmans关于如何添加oData提要的示例,该示例不涉及通过web.config配置wcf。

WCF 4的工作方式是,如果值是默认值,则不需要存在。因此,如果您不单独配置服务,则需要更改默认的服务行为。

您可以通过配置服务行为来实现,例如:

<configuration>
 <system.serviceModel>
  <behaviors>
  <serviceBehaviors>
    <behavior> <!-- notice no name attribute -->
     <serviceMetadata httpGetEnabled="true" /> 
     <serviceDebug includeExceptionDetailInFaults="true" /> 
     <IPFilter filter="172.*.*.* 127.0.0.1" />           
    </behavior>
   </serviceBehaviors>
   </behaviors>
 </system.serviceModel>
</configuration>

最新更新