2

BundleConfig.cs snippet

    public static void RegisterBundles(BundleCollection bundles)
    {
        bundles.Add(new StyleBundle("~/bundles/css").Include(
                    "~/content/themes/base/jquery.ui.core.css",
                    "~/content/themes/base/jquery.ui.theme.css"
    }

_Layout.cshtml snippet

@Styles.Render("~/bundles/css")

jquery.ui.theme.css snippet

    url(images/ui-bg_flat_75_ffffff_40x100.png)

Firebug reports that the image (my_app_path) / bundles / images / ui-bg_flat_75_ffffff_40x100.png` 404 not found.

How can I tell Razor that the correct path is actually (my_app_path) / content / themes / base / images / ui-bg_flat_75_ffffff_40x100.png`?

EDIT: ELMAH spits this error for the same issue:

System.Web.HttpException: The controller for path ' / bundles / images / ui-bg_flat_75_ffffff_40x100.png' was not found or does not implement IController.

joym8
  • 3,047
  • 2
  • 34
  • 68

1 Answers1

-1

This is happening because your CSS files aren't being rewritten to transform their relative paths. You can make this happen by changing to the following:

bundles.Add(new StyleBundle("~/bundles/css").Include(
                "~/content/themes/base/jquery.ui.core.css",
                "~/content/themes/base/jquery.ui.theme.css",
                new CssRewriteUrlTransform()));
Richard
  • 27,531
  • 8
  • 67
  • 116
  • I'm sure this will work but for some reason it seems like a workaround. I may be wrong but was hoping to get a solution without having to edit the css file or move files around. – joym8 May 25 '16 at 13:29
  • Indeed. Found a better solution [here](http://stackoverflow.com/a/11386982/163495) and updated the answer to reflect that. – Richard May 25 '16 at 13:55
  • in [that link](http://stackoverflow.com/a/11386982/163495) there is also a comment by avidenic that this may only work for websites in IIS and not applications under the website. mine is an application. nevertheless i tried. couple of things - needed to update system.web.optimization from 1.0.0 to latest version to resolve CssRewriteUrlTransform. and now i get `cannot convert type CssRewriteUrlTransform to string` build error. i just ended up taking a totally different route - added two bundles instead of one - separating them based on folder locations. – joym8 May 25 '16 at 14:26
  • There is no such overloaded method of the `.Include()` one. I have tried to split them to different `.Include()` calls but it it doesn't work. This doesn't work until you change the bundle virtual path to `"~/Content/themes/base/css"` instead of the `"~/bundles/css"` – SerjG Dec 19 '16 at 18:17