简体   繁体   中英

Does WCF service method have something equivalent to ASP.NET Application_EndRequest?

I want to Dispose of some objects that are created during a WCF service method, but I need to clean them up outside of the scope of the method that created them. When I'm working in ASP.NET, I normally call that code during the Application_EndRequest event.

If the answer is: there is no Application_EndRequest -like event in WCF, how should I go about cleaning up my objects?

You can implement IDisposable for your WCF service. If the service is configured PerSession or PerCall * context mode * dispose method will be called once the channel is closed and the service instance is dropped.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM