1

My ASP.Net MVC 4 site runs great inside of Visual Studio 2013, however, in preperation for deployment, I tried to "publish" to my local instance of IIS, and my style/script bundles don't seem to be working.

I setup a new site in IIS:

IIS Config

And created a publish profile in visual studio:

Visual Studio Publish Profile

But it looks like something isn't executing correctly.

Working home page source sample (when running in visual studio)

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Home Page - My ASP.NET Application</title>

    <link href="/Content/css/bootstrap.min.css" rel="stylesheet"/>
    <link href="/Content/css/font-awesome.min.css" rel="stylesheet"/>
    <link href="/Content/css/animate.min.css" rel="stylesheet"/>
    <link href="/Content/css/lightbox.css" rel="stylesheet"/>
    <link href="/Content/css/syntax/shCore.css" rel="stylesheet"/>
    <link href="/Content/css/syntax/shThemeDefault.css" rel="stylesheet"/>
    <link href="/Content/css/color-default.css" rel="stylesheet"/>
    <link href="/Content/css/width-full.css" rel="stylesheet"/>
    <link href="/Content/css/style.css" rel="stylesheet"/>

    <link href="/Content/css/LESS/lba.less" rel="stylesheet"/>

    <script src="/Scripts/modernizr-2.6.2.js"></script>

Non working home page source sample (from IIS)

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <title>Home Page - My ASP.NET Application</title>

    <link href="/Content/css?v=KKy3Sm_C-GIW_Hs_Kz3iGW2JCKsc0-x42GPtfoGzMKs1" rel="stylesheet"/>

    <link href="/Content/css/LESS?v=V3zOrniKjzcAwQn95ck_IGMcC8gvUmcHC3PpOi1mL_M1" rel="stylesheet"/>

    <script src="/bundles/modernizr?v=wBEWDufH_8Md-Pbioxomt90vm6tJN2Pyy9u9zHtWsPo1"></script>

As a bit of final info - the links/routes appear to be working (i.e. pages load when I click on the links).

Update 1

relevant portion of _Layout.cshtml

 @Styles.Render("~/Content/css")
 @Styles.Render("~/Content/css/LESS")
 @Scripts.Render("~/bundles/modernizr")

BundleConfig.cs

namespace Lubbock_Baseball_Academy
{
    public class BundleConfig
    {
        // For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
        public static void RegisterBundles(BundleCollection bundles)
        {
            bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
                        "~/Scripts/jquery-{version}.js"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                        "~/Scripts/jquery.validate*"));

            // Use the development version of Modernizr to develop with and learn from. Then, when you're
            // ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
            bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
                        "~/Scripts/modernizr-*"));

            bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
                      "~/Scripts/bootstrap.js",
                      "~/Scripts/respond.js"));

            bundles.Add(new StyleBundle("~/Content/css").Include(
                      "~/Content/css/bootstrap.min.css",
                      "~/Content/css/font-awesome.min.css",
                      "~/Content/css/animate.min.css",
                      "~/Content/css/lightbox.css",
                      "~/Content/css/syntax/shCore.css",
                      "~/Content/css/syntax/shThemeDefault.css",
                      "~/Content/css/color-default.css",
                      "~/Content/css/width-full.css",
                      "~/Content/css/style.css"));

            bundles.Add(new ScriptBundle("~/bundles/theme").Include(
                       "~/Scripts/jquery-1.10.2.min.js",
                       "~/Scripts/jquery.cookie.js",
                       "~/Scripts/bootstrap.min.js",
                       "~/Scripts/jquery.mixitup.min.js",
                       "~/Scripts/lightbox-2.6.min.js",
                       "~/Scripts/holder.js",
                       "~/Scripts/app.js"));


            bundles.Add(new LessBundle("~/Content/css/LESS").Include(
                        "~/Content/css/LESS/*.less"));
        }
    }
}
drewwyatt
  • 5,989
  • 15
  • 60
  • 106
  • 1
    "My style/script bundles don't seem to be working" How so? What happens when you navigate the the `href` in the link for a stylesheet? – MikeSmithDev Mar 03 '14 at 16:36
  • Take a look at the 2 examples I gave - notice in the working example, 9 stylesheet links are created, but when launching the site from IIS, I get the 2nd source output, with 2 busted stylesheet links – drewwyatt Mar 03 '14 at 16:40
  • That's how bundling works. You get individual scripts in debug mode, and a single bundled script in release mode. Try renaming your bundle, as you can't give them the same name as a directory, per the answer I linked to. – MikeSmithDev Mar 03 '14 at 16:41
  • possible duplicate of [Bundling scripts are not getting rendered](http://stackoverflow.com/questions/15540528/bundling-scripts-are-not-getting-rendered) – MikeSmithDev Mar 03 '14 at 16:42
  • @MikeSmithDev Thanks, I didn't know that about bundling. I don't think I have any duplicate bundle names though. I just added an update showing my bundles and how they are rendered in the view. Does that help? – drewwyatt Mar 03 '14 at 16:45
  • 2
    Your bundle name `/Content/css` is the same name as a directory... Please see my other post. – MikeSmithDev Mar 03 '14 at 16:46
  • @MikeSmithDev I misunderstood you. Sorry. Taking a look right now. If it works I'll let you know so that you can post an answer. – drewwyatt Mar 03 '14 at 16:46
  • @MikeSmithDev That was the issue. Fixed! Can you post this as an answer so that I can mark you as accepted? – drewwyatt Mar 03 '14 at 16:49
  • No! I voted to close as duplicate :) No need to copy/paste answers. – MikeSmithDev Mar 03 '14 at 16:51

0 Answers0