Wrap the retrieval of HTTP context in try/catch since it might fail in circumstances where the HTTP context is available, but not yet bootstrapped (like in ASP.NET Application Start and such).