MVC Bundling and CSS relative URLs

Viewed 46048

MVC's bundling is returning the wrong URL in CSS images when using CssRewriteUrlTransform:

I have an intranet application whose URL is, for example: http://usid01-srv002/MyApplication. It's in IIS's "Default Web Site".

Which has the following in BundleConfig.cs:

bundles.Add(new StyleBundle("~/bundles/jcss")
    .Include("~/Scripts/JQueryUI/css/*.css", new CssRewriteUrlTransform())
);

The bundling system is generating the wrong URL for any images referenced in those CSS files, yielding 404's even JQueryUI's very well tested CSS files (from FireBug):

404 errors due to wrong generated URL

e.g. it's generating

http://usid01/path/foo.png

When it should be generating:

http://usid01/MyApplication/path/foo.png

How do I get the bundling system to generate a URL that points to the right location?

3 Answers
Related