Setting WCF InstanceContextMode (Per Call, Single) in web.confg

巧了我就是萌 提交于 2019-12-04 00:13:54
Ladislav Mrnka

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.

Processing in WAS is the same - each service type still have its own service host and each request is processed in its own thread.

You can not configure InstanceContextMode and ConcurrencyMode in config files, build in limitation in the WCF, i am sure MS has their reasons.

About hosting in WAS, if you have a web server with IIS 7/7.5 it is recommended to host your service with WAS because you can manage your services with the IIS management and get a lot of built in capabilities from it.

As per the previous answers, you cannot do this without a bit of work. I had to do this for a customer recently and I have documented it here. I have also provided a validator to not allow the service to start if it is not configured how you would like it. The details are here changing-wcf-concurrency-programatically.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!