IIS 托管 (http) WCF 服务的生命周期是什么? [英] What is the lifecycle of an IIS-hosted (http) WCF service?

查看:29
本文介绍了IIS 托管 (http) WCF 服务的生命周期是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在我的应用程序中设置了一个依赖注入容器,我认为每次收到 WCF 服务请求时组合容器的效率都会很低.

I have a dependency injection container setup in my application and I'm thinking that composing the container every time a WCF service request comes in is going to be inefficient.

有人可以向我解释一下,对于 http/IIS 托管的 WCF 服务,该服务的生命周期是什么?如果我能弄清楚这一点,我就可以对容器的存储、实例化、销毁等位置做出明智的决定.

Can somebody explain to me, for an http/IIS hosted WCF service, what the lifecycle of the service is? If I can figure this out, I can make an educated decision on where the container is to be stored, instantiated, destroyed, etc.

推荐答案

如果你的 InstanceContextModePerCall,服务类将从头开始为每个传入的请求创建,然后在完成后处理掉.

If your InstanceContextMode is PerCall, the service class will be created from scratch for every incoming request, and then disposed of when it's done.

如果您的 InstanceContextModePerSession,则服务类将被创建并用于在会话期间(或直到InactivityTimeout"是遇到,或发生错误).

If your InstanceContextMode is PerSession, the service class will be created and used to service one given client for the duration of the session (or until an "InactivityTimeout" is encountered, or an error occurs).

如果您的 InstanceContextModeSingle(单例),服务类将在第一个请求进来时创建,并且只要请求不断进来就会留在内存中,只要没有发生错误并且没有达到 inactivityTimeout.

If your InstanceContextMode is Single (singleton), the service class will be created when the first request comes in and will stay in memory as long as requests keep coming in, as long as no error occurs and no inactivityTimeout is reached.

所以,你有它!当然,并发模式(用于 PerSessionSingle 服务)也将发挥作用,让事情变得更有趣"

So, there you have it! Of course, the concurrency mode (for PerSession and Single services) will also come into play to make things just a tad more "interesting"

这篇关于IIS 托管 (http) WCF 服务的生命周期是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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