Just solved a problem at work:
If is giving you null or an exception or not working, there are several possibilities. One of them is you didn't enable asp.net compatibility mode.
Better off to migrate to another way of finding the server path than depending on HttpContext though,
HttpContext is bad to depend on, when dealing with WCF or non-MVC applications (there isn't always a context.)
Hope this helps someone