Search code examples
bundleasp.net-optimizationvirtualpathprovider

Workaround for Bundling under Virtual Path Providers


I found that under ASP.NET MVC 4 you can't define a bundle of Javascripts or CSSs if their virtual path is managed by a VirtualPathProvider. I mean, if directory "~/Static/" is mapped to a VPP you can't Include("~/Static/Stylesheets/themes/dark-blue.css") because it will simply and silently fail.

From here and here it really looks like this is the default behaviour of runtime, because it basically resolves the virtual path on file system rather than using ASP.NET pipeline. And, fortunately, it's to be implemented in next MVC.

Anyway, since this looks like being a common problem, and since I'm going to store static resources outstide of the project (ultimately on Azure's CDN, but I still have to develop&debug), did anyone find a workaround to let ASP.NET Web Optimization search for resources in their virtual paths?


Solution

  • VirtualPathProvider support is in the 1.1-alpha1 version of Optimization, have you tried that version out? It should support resolving files through your VPP.