I would like to explicitly \"release\" object instance resolved by Unity. I hoped the Teardown method should be used exactly for this so I tried something like this:
Unity TearDown doesn't do anything out of the box. You do not need to remove from HttpContext.Current.Items as it will be cleared automatically at the end of the request. What you may want to do is call Dispose on any IDisposable object stored there. You would do this from EndRequest in Global.asax:
foreach (var item in HttpContext.Current.Items.Values)
{
var disposableItem = item as IDisposable;
if (disposableItem != null)
{
disposableItem.Dispose();
}
}