jetheredge/SquishIt — Issue #94: AsCached() throws exception at application start
Author: laurentlbm
Created: 2011-11-08 14:47:34+00:00
State: open

I get the following exception :

[HttpException (0x80004005): Request is not available in this context]
System.Web.HttpContext.get_Request() +11492450
SquishIt.Framework.FileSystem.ResolveFileSystemPathToAppRelative(String file) +157
SquishIt.Framework.Base.BundleBase`1.RenderDebug(String name) +2197
SquishIt.Framework.Base.BundleBase`1.Render(String renderTo, String key, IRenderer renderer) +188
SquishIt.Framework.Base.BundleBase`1.AsCached(String name, String filePath) +210

The problem is in SquishIt.Framework.FileSystem, function ResolveFileSystemPathToAppRelative:

var root = HttpContext.Current != null
? new Uri(HttpContext.Current.Request.PhysicalApplicationPath)
: new Uri(Directory.GetDirectoryRoot(Environment.CurrentDirectory));

Should be:

var root = HttpContext.Current != null
? new Uri(Directory.GetDirectoryRoot(Environment.CurrentDirectory))
: new Uri(HttpContext.Current.Request.PhysicalApplicationPath);