seesharper/LightInject — pull request #143 by geirsagberg (2014-12-17 12:01:22+00:00)
Title: Use HttpApplication.Context instead of HttpContext.Current

I had a problem when adding the [HSTS IIS module](https://hstsiis.codeplex.com/). When redirecting from http to https, LightInject would fail with the following stack trace:
```
[NullReferenceException: Object reference not set to an instance of an object.]
LightInject.Web.LightInjectHttpModule.EndRequest() in c:\Users\bri\Documents\GitHub\LightInject\NuGet\Build\Net45\LightInject.Web\LightInject.Web.cs:110
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +91
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +164
```
The error was caused by `HttpContext.Current` being `null`. To avoid this, I modified `LightInject.Web` to instead use the event sender's HttpContext, as this will never be null. This is also how e.g. Unity does it in [UnityPerRequestHttpModule](https://unity.codeplex.com/SourceControl/latest#source/Unity.Mvc/Src/UnityPerRequestHttpModule.cs).