asp.net - <endpointBehaviors> 和 <serviceBehaviors> 之间的区别

标签 asp.net wcf

我不确定我是否理解 web.config 元素之间的区别 <endpointBehaviors><serviceBehaviors> (当然还有邻近的行为)。

最佳答案

来自here :

  1. ServiceBehavior applies only on service while EndpointBehavior applies on both client and service.

  2. ServiceBehavior can be specified via config/attribute/code while endpointbehavior can be specified via config/code.

  3. ServiceBehavior has access to all ServiceEndpoints dispatch runtime and so could modify all dispatch runtimes while Endpointbehavior gets called with the runtime for that endpoint only.

Look at it this way, ServiceBehavior lets you access runtime parameters for all endpoints while Endpointbehavior lets you access runtime components only for that endpoint. So if you have a need to extend functionality that spawns the entire contract (or multiple contracts) then use ServiceBehavior and if you are interested in extending one specific endpoint then use Endpointbehavior.

还有MSDN可以随时引用以获取详细信息:

<endpointBehaviors> This configuration section represents all the behaviors defined for a specific endpoint.

<serviceBehaviors> This configuration section represents all the behaviors defined for a specific service.

一个很好的 MSDN 引用:Configuring and Extending the Runtime with Behaviors

关于asp.net - <endpointBehaviors> 和 <serviceBehaviors> 之间的区别,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34526228/

相关文章:

c# - 如何获取 Entity Framework 中的特定列

c# - 我可以让 WebApi 与 IoC Aspects/Interceptor 一起工作吗

asp.net - 无法加载文件或程序集 App_Web_xxxxxxxx 或其依赖项之一

WCF Rest ERR_CONNECTION_RESET 响应不大

wcf - 如何测试 WCF 超时设置?

c# - 中继器内的 DropDownList : How to handle SelectedIndexChange and get DataItem?

asp.net - session 超时后出现网络错误 : 500 System. ServiceModel.ServiceActivationException

c# - cssclass 不适用于复选框列表

c# - 自定义控件属性作为枚举

c# - 如何为数百个并发连接优化/设计 WCF?