Using HttpContext.Current is gennerally considered a bad thing for several reasons like mocking and testability. The following has proven to be working as an alternative: https://gist.github.com/3194281