开发者

Do I need to dispose a web service reference in ASP.NET? Can I use a singleton?

开发者 https://www.devze.com 2023-03-02 03:25 出处:网络
Do I really need to dispose a SoapHttpClientProtocol object? Is it better practice to use the instance as a Singleton in ASP.Net?

Do I really need to dispose a SoapHttpClientProtocol object?

Is it better practice to use the instance as a Singleton in ASP.Net?

This says that SoapHttpClientProtocol is Thread Safe:

http://msdn.microsoft.com/en-us/library/sy开发者_C百科stem.web.services.protocols.soaphttpclientprotocol.aspx.


The fact that it is thread-safe means that using it as singleton will reduce your site almost to a single-threaded application.

Proxies - especially for a web application - should always be created as temporary object inside a using block (although in WCF it needs to be a different approach). This approach will have its overhead of creating a proxy every time but is the safest approach. This will prevent different clients of the ASP.NET application clashing with each other or using a closed or faulted proxy.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号