I am not sure to fully understand your problem, but seeing http://localhost
here seems wrong. You should never use an absolute URL for your bundles.
For me CssRewriteUrlTransform works perfectly, here is how I use it:
bundles.Add(new StyleBundle("~/bundles/css").Include(
"~/Content/css/*.css", new CssRewriteUrlTransform()));
"Bundles" is virtual.
Does this helps?
Update
I was confused with the "VirtualDir" thing, as you are talking about IIS VirtualDir, and I was thinking Bundle VirtualDir! It's true that in this case CssRewriteUrlTransform will rewrite URLs to the Host, not to the Host/VirtualDir URI.
To do that, you have to derive CssRewriteUrlTransform to make it do what you need it to.
There is a good discussion here: ASP.NET MVC4 Bundling with Twitter Bootstrap
Seems the best answer is there:http://aspnetoptimization.codeplex.com/workitem/83
public class CssRewriteUrlTransformWrapper : IItemTransform
{
public string Process(string includedVirtualPath, string input)
{
return new CssRewriteUrlTransform().Process("~" + VirtualPathUtility.ToAbsolute(includedVirtualPath), input);
}
}
Use this class instead of CssRewriteUrlTransform
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…