WCF ChannelFactory and Channel caching in ASP.NET client application

▼魔方 西西 提交于 2019-12-03 07:37:59

Ideally close the channel as soon as you are done with it. This will place it back into the channel pool so it can be used by another worker thread.

Yes, the channel factory (the expensive bit) can remain for the lifetime of the application.


Update

As of .Net 4.5 there is a built in caching options for factories ChannelFactory Caching .NET 4.5

This is an aside. Why are you using SessionID as a context key? The context.Items is unique per request. That is:

HttpContext.Current.Items[HttpContext.Current.Session.SessionID +"_ListOfOpenedChannels"]

should be functionally equivalent to:

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