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

StackOverflow https://stackoverflow.com/questions/22700191

  •  22-06-2023
  •  | 
  •  

Вопрос

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top