Reputation: 14586
I'm injecting a wcf service into a controller using Unity. However I've noticed there's no way to close the service. How can I make sure the connection to the service gets closed after the service method returns ?
public ITiers TierClient { get; set; }
public HomeController(ITiers tierClient)
{
TierClient = tierClient;
}
public ActionResult Index()
{
ViewBag.Message = "Welcome to ASP.NET MVC!";
bool result = TierClient.CheckIfTierExiste("***", "***", null, true);
return View();
}
Upvotes: 0
Views: 192
Reputation: 1038710
You could use a custom lifetime manager
for this dependency. I would recommend you using the Unity.MVC3
NuGet package which registers a custom dependency resolver and this custom lifetime manager allowing you to handle IDisposable
resources.
Upvotes: 1