public override object Resolve(CreationContext context, IReleasePolicy releasePolicy) { var current = HttpContext.Current; if (current == null) { throw new InvalidOperationException( "HttpContext.Current is null. PerWebRequestLifestyle can only be used in ASP.Net"); } var cachedBurden = (Burden)current.Items[perRequestObjectId]; if (cachedBurden != null) { return(cachedBurden.Instance); } PerWebRequestLifestyleModule.EnsureInitialized(); var burden = base.CreateInstance(context, true); current.Items[perRequestObjectId] = burden; PerWebRequestLifestyleModule.RegisterForEviction(this, burden); Track(burden, releasePolicy); return(burden.Instance); }