在 web.confg 中设置 WCF InstanceContextMode (Per Call, Single) [英] Setting WCF InstanceContextMode (Per Call, Single) in web.confg
问题描述
在谷歌上搜索了很多,还没有遇到过这个.
Haven't come across this one with quite a bit of Googling.
我知道我可以通过修饰类名来设置实例:
I know I can set the instance by decorating the class name thus:
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall,
ConcurrencyMode = ConcurrencyMode.Multiple)]
但是我可以在 web.config
文件中指定它吗?
but can I specify this in the web.config
file?
我知道我可以在 web.config
/app.config
中指定限制(最大并发用户数等),并且这里的数字根据实例具有上下文模式 - 但是如何指定模式(很可能是 app.config
/web.config
的行为部分)?
I know I can specify throttling (max concurrent users etc) in the web.config
/ app.config
and that the numbers here have a context depending on the instance mode - but how to specify the mode (in most likely the behaviours section of the app.config
/ web.config
)?
最初我们打算使用 Windows 服务.现在我们正在使用 WAS.WAS 有什么不同吗 - 例如.每个每次调用"请求仍将获得它自己的服务器"作为管道操作?
Originally we were going for Windows services. Now we are using WAS. Does WAS make any difference - eg. each 'per call' request will still get's it own 'server' as a pipeline operation?
谢谢
推荐答案
您不能使用开箱即用的功能更改 web.config 中的 InstanceContextMode
和 ConcurrencyMode
您可以编写自定义扩展(行为或自定义 ServiceHost
+ ServiceHostFactory
+ 配置部分)来做到这一点.示例如下如何更改 InstanceContextMode
而无需在服务类的属性中定义它.
You can't change InstanceContextMode
and ConcurrencyMode
in web.config with out of the box functionality but you can write your custom extension (behavior or custom ServiceHost
+ ServiceHostFactory
+ config section) to do that. Here is the example how to change InstanceContextMode
without defining it in attribute on the service class.
WAS 中的处理是相同的——每个服务类型仍然有自己的服务主机,每个请求都在自己的线程中处理.
Processing in WAS is the same - each service type still have its own service host and each request is processed in its own thread.
这篇关于在 web.confg 中设置 WCF InstanceContextMode (Per Call, Single)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!