mwrock / RequestReduce

Instantly makes your .net website faster by reducing the number and size of requests with almost no effort.
www.requestreduce.org
Apache License 2.0
228 stars 48 forks source link

SpriteVirtualPath not correctly mapped #189

Closed jaap34 closed 12 years ago

jaap34 commented 12 years ago

When not using the web.config, but WebActivator.PreApplicationStartMethod to configure and initialize RequestReduce, something goes wrong with the output path of the resources.

The code:

[assembly: WebActivator.PreApplicationStartMethod(typeof(RequestReduceConfiguration), "Start")]
namespace Framework.UI.Resources
{
    public static class RequestReduceConfiguration
    {
        public static void Start()
        {
            DynamicModuleUtility.RegisterModule(typeof(RequestReduceModule));
            RequestReduce.Api.Registry.Configuration.SpriteVirtualPath = "~/repository/cache";
        }
   }
}

The output in the HTML becomes:

~/repository/cache/4556dbb543035982a75b0059a0806b18-6db26c880265f8bd42293e18e1fea26a-RequestReducedScript.js

(should be absolute url)

Though the files are correctly combined and minified and stored to the specified path.

jaap34 commented 12 years ago

I have managed to get it working by setting the paths as following;

RequestReduce.Api.Registry.Configuration.SpritePhysicalPath = HostingEnvironment.MapPath("~/repository/cache");
RequestReduce.Api.Registry.Configuration.SpriteVirtualPath = Utility.ResolveUrl("~/repository/cache");

Utility.ResolveUrl is a custom method which resolves relative to absolute url.

jaap34 commented 12 years ago

Shouldn't the Configuration properties behave in the same way as the properties in web.config?

mwrock commented 12 years ago

hard to argue that. yes.

candrews commented 12 years ago

Could this problem be the same problem as #191?

mwrock commented 12 years ago

This is most likely unrelated. The problem was that the SpriteVirtualPath was being translated to the absolute path at initialization of the configuration and never again. So passing in new values through the API were not resolving the tilde.