以编程方式添加 IOperationBehavior 的正确位置在哪里 [英] where is the right place to add IOperationBehavior programmatically

查看:31
本文介绍了以编程方式添加 IOperationBehavior 的正确位置在哪里的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 iis 上运行时如何以编程方式添加 IOperationBehavior?不在自定义 wcf 主机上.

how can i add IOperationBehavior programmatically when running on iis ? not on custom wcf host.

谢谢

阿里·塔卡维奇

推荐答案

您需要构建一个 自定义服务主机,然后设置您的 .svc 文件以使用它.在自定义服务主机中,您可以在服务启动之前对其进行任何您喜欢的操作,包括设置行为.因为要使用操作行为,所以应该在 OnOpening() 方法中进行 - 因为服务工厂应用在配置端点行为后重置操作行为.您将能够遍历端点和 OnOpening 中的操作.

You need to build a custom service host, then set your .svc file to use it. In the custom service host you can do whatever you like to the service before it starts, including setting behaviours. Because you want to use operation behaviours you should do it in the OnOpening() method - as the service factory applies resets the operation behaviours after endpoint behaviours are configured. You will be able to iterate through the endpoints and the operations in OnOpening.

这篇关于以编程方式添加 IOperationBehavior 的正确位置在哪里的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆