0

I am using Bundling for my CSS and use that in my MVC Layout.cshtml page. The CSS files are included correctly but the icons are not shown properly.

Should i do something to include icons?

MY Bundle code

 bundles.Add(new StyleBundle("~/Content/css").Include(
            "~/Content/Site.css",
            "~/Content/ej/web/ej.widgets.core.min.css",
            "~/Content/ej/web/default-theme/ej.theme.min.css",
            "~/Content/TodoList.css")); 

I am using it in my page as follow

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

But i am getting as follow.

enter image description here

Thanks in advance.

Regards, Madhu

AbdulRahman Ansari
  • 3,007
  • 1
  • 21
  • 29
Madhu
  • 2,416
  • 3
  • 15
  • 33

3 Answers3

1

You might need to use CssRewriteUrlTransform.

Rewrites urls to be absolute so assets will still be found after bundling.

Your code might look something like

bundles.Add(new StyleBundle("~/Content/css")
    .Include("~/Content/Site.css")
    .Include("~/Content/ej/web/ej.widgets.core.min.css",
        new CssRewriteUrlTransform())
    .Include("~/Content/ej/web/default-theme/ej.theme.min.css",
        new CssRewriteUrlTransform())
    .Include("~/Content/TodoList.css"));
Rowan Freeman
  • 15,724
  • 11
  • 69
  • 100
  • Thanks but i cant find the `CssRewriteUrlTransform` in `System.Web.Optimization`? Where could i find it? – Madhu May 13 '14 at 06:25
  • Make sure you have the [Microsoft ASP.NET Web Optimization Framework](https://www.nuget.org/packages/Microsoft.AspNet.Web.Optimization/). – Rowan Freeman May 13 '14 at 06:33
0

Specify normal .css files. .Net will automatically pick .min.css files in Release Mode. Make sure both .css and .min.css have Image urls.

bundles.Add(new StyleBundle("~/Content/css").Include(
            "~/Content/Site.css",
            "~/Content/ej/web/ej.widgets.core.css",
            "~/Content/ej/web/default-theme/ej.theme.css",
            "~/Content/TodoList.css")); 
malkam
  • 2,337
  • 1
  • 14
  • 17
0

I found the reason and the solution for my issue. I provided the virtual path incorrectly. I changed it as follow and now its working fine.

 // Content css
        bundles.Add(new StyleBundle("~/Content/css").Include(
            "~/Content/Site.css")              
            .Include("~/Content/TodoList.css"));

 // Content ej css
        bundles.Add(new StyleBundle("~/Content/ej/web/css")
        .Include("~/Content/ej/web/ej.widgets.core.min.css")
        .Include("~/Content/ej/web/default-theme/ej.theme.min.css"));
Madhu
  • 2,416
  • 3
  • 15
  • 33