Why is my CSS bundling not working with a bin deployed MVC4 app?
Asked Answered
O

20

68

I have bin deployed an MVC4 application to my hosting provider, based on advice given here and one or two on-the-fly fixes, but the most immediately apparent problem is that the bundling for css doesn't work. When I replace the bundle ref with explicit file refs, my css works again.

I am using a standard MVC4 RTM project template from VS2012. The provider is running IIS 7.5 and ASP.NET 4, and my previous MVC3 version of the same app worked fine. I am guessing I have grabbed a dependency somewhere of too low a version, and this might also contribute to my area based action link problem.

Technical symptoms are:

The line @Styles.Render("~/Content/css") renders as <link href="/Content/css?v=" rel="stylesheet"/>

Opportunity answered 16/8, 2012 at 10:40 Comment(4)
Have you set <compilation debug="false" /> in your web config or BundleTable.EnableOptimizations = true; in your BundleConfig method? How are you bundle setup and Styles.Render call look like? How is the generated url looks like? If you feel that you have a dependency version mismatch problems I suggest to do a clear install of MVC4 RTM create a new project and copy over the files...Edomite
Debug="false" can't be required, or the bundles wouldn't work in my debug release. But thank, great news that MVC4 is RTM.Opportunity
Can you elaborate on but the most immediately apparent problem is that the bundling for css doesn't work part? How is it not working? Do you see the bundle reference in the output?Stoffel
How you solved the problem finally? I have the same issue, but none of these solutions do not solve the problem..Nary
C
79

The CSS and Script bundling should work regardless if .NET is running 4.0 or 4.5. I am running .NET 4.0 and it works fine for me. However in order to get the minification and bundling behavior to work your web.config must be set to not be running in debug mode.

<compilation debug="false" targetFramework="4.0">

Take this bundle for jQuery UI example in the _Layout.cshtml file.

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

If I run with debug="true" I get the following HTML.

<link href="/Content/themes/base/jquery.ui.core.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.resizable.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.selectable.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.accordion.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.autocomplete.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.button.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.dialog.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.slider.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.tabs.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.datepicker.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.progressbar.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.theme.css" rel="stylesheet"/>

But if I run with debug="false". I'll get this instead.

<link href="/Content/themes/base/css?v=myqT7npwmF2ABsuSaHqt8SCvK8UFWpRv7T4M8r3kiK01" rel="stylesheet"/>

This is a feature so you can easily debug problems with your Script and CSS files. I'm using the MVC4 RTM.

If you think it might be an MVC dependency problem, I'd recommend going into Nuget and removing all of your MVC related packages, and then search for the Microsoft.AspNet.Mvc package and install it. I'm using the most recent version and it's coming up as v.4.0.20710.0. That should grab all the dependencies you need.

Also if you used to be using MVC3 and are now trying to use MVC4 you'll want to go into your web.config(s) and update their references to point to the 4.0 version of MVC. If you're not sure, you can always create a fresh MVC4 app and copy the web.config from there. Don't forget the web.config in your Views/Areas folders if you do.

UPDATE: I've found that what you need to have is the Nuget package Microsoft.AspNet.Web.Optimization installed in your project. It's included by default in an MVC4 RTM app regardless if you specify the target framework as 4.5 or 4.0. This is the namespace that the bundling classes are included in, and doesn't appear to be dependent on the framework. I've deployed to a server that does not have 4.5 installed and it still works as expected for me. Just make sure the DLL gets deployed with the rest of your app.

Clothier answered 22/8, 2012 at 18:40 Comment(8)
The Microsoft documentation also seems to indicate this is a .NET 4.5 feature only. Not saying it's not running for you, but maybe you have a reference to 4.5 on your system somewhere?Stoffel
Updated my answer with some information I found regarding the namespace.Clothier
@JoeyGennari The MSDN doc page shows when it first shipped as a part of .NET. You'd need to check the history of the Nuget package to know when the team first shipped it out-of-band.Krasner
@JoeyGennari the optimization stuff requires ASP.NET 4.5 which runs on .NET 4. A little version confusion for us all there.Keijo
Why should I use Debug=true in a production server? just for having the bundles render the css paths correctly? Or am I misunderstanding your solution? I have this very problem with an MVC5 site, and I also have the nuget packages installed in the solution.Slatternly
You don't have to. The Debug flag in the web.config is just what the minification/bundling logic uses to determine if they should be applied or not. Debugging minified JS is a pain so it will not by default apply it to a site running in debug mode or when EnableOptimizations is set to false. If you don't want them all combined to one per bundle you can turn it off using the EnableOptimizations property.Clothier
When I right click on the project to deploy to Azure, if Settings -> Configuration is set to 'Release', then my css is blocked by permissions. If I set to 'Debug', my site loads correctly. ...strange.Chronister
its 2020 now and the solution still worked like knife through butter... I was struggling for quite sometime on thisBellini
P
83

UPDATE 11/4/2013:

The reason why this happens is because you have .js or .css at the end of your bundle name which causes ASP.NET to not run the request through MVC and the BundleModule.

The recommended way to fix this for better performance is to remove the .js or .css from your bundle name.

So /bundle/myscripts.js becomes /bundle/myscripts

Alternatively you can modify your web.config in the system.webServer section to run these requests through the BundleModule (which was my original answer)

<modules runAllManagedModulesForAllRequests="true">
  <remove name="BundleModule" />
  <add name="BundleModule" type="System.Web.Optimization.BundleModule" />
</modules>

Edit: I also noticed that if the name ends with 'css' (without the dot), that is a problem as well. I had to change my bundle name from 'DataTablesCSS' to 'DataTablesStyles' to fix my issue.

Proton answered 28/11, 2012 at 3:10 Comment(9)
I have not seen this written anywhere else. I was trying to bundle on Server 2008/IIS 7/.NET 4 and this was exactly what was missing.Astri
Thanks! This is the only thing that worked for me. B.T.W this also works with runAllManagedModulesForAllRequests="false" for me. Would love to know why I needed this though.Gouty
This solution is the one that finally fixed my problem!Judyjudye
Rob Bird runAllManagedModulesForAllRequests is not related to the solution. You can read Kurt's comment above as to why its a bad idea to have this setting enabledSpringspringboard
@SameerAlibhai check my updated answer for more details. runAllManagedModulesForAllRequests is "related" but you're correct it's not the best solution.Proton
Note that, at least in framework 4.5 with all those lovely bells and whistles that it need not be ".css" but "css" in the bundle name is enough to make it pitch a fit.Upholstery
CDeutsch - You are my hero. I cannot thank you enough. The issue in my case was a styles bundle name ending with css (your edit note). I din't have to do any other fixups other than change the name to "mystyles" instead of "mycss".Tootsie
I'm impressed. At first, I did think the fact that it ended with css had no link at all... I changed my Content/css by Content/styles and now it works. Quite the surprise. Thanks!Fritzfritze
its resolved my issue with <modules runAllManagedModulesForAllRequests="false"> thanks.Bac
C
79

The CSS and Script bundling should work regardless if .NET is running 4.0 or 4.5. I am running .NET 4.0 and it works fine for me. However in order to get the minification and bundling behavior to work your web.config must be set to not be running in debug mode.

<compilation debug="false" targetFramework="4.0">

Take this bundle for jQuery UI example in the _Layout.cshtml file.

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

If I run with debug="true" I get the following HTML.

<link href="/Content/themes/base/jquery.ui.core.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.resizable.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.selectable.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.accordion.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.autocomplete.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.button.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.dialog.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.slider.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.tabs.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.datepicker.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.progressbar.css" rel="stylesheet"/>
<link href="/Content/themes/base/jquery.ui.theme.css" rel="stylesheet"/>

But if I run with debug="false". I'll get this instead.

<link href="/Content/themes/base/css?v=myqT7npwmF2ABsuSaHqt8SCvK8UFWpRv7T4M8r3kiK01" rel="stylesheet"/>

This is a feature so you can easily debug problems with your Script and CSS files. I'm using the MVC4 RTM.

If you think it might be an MVC dependency problem, I'd recommend going into Nuget and removing all of your MVC related packages, and then search for the Microsoft.AspNet.Mvc package and install it. I'm using the most recent version and it's coming up as v.4.0.20710.0. That should grab all the dependencies you need.

Also if you used to be using MVC3 and are now trying to use MVC4 you'll want to go into your web.config(s) and update their references to point to the 4.0 version of MVC. If you're not sure, you can always create a fresh MVC4 app and copy the web.config from there. Don't forget the web.config in your Views/Areas folders if you do.

UPDATE: I've found that what you need to have is the Nuget package Microsoft.AspNet.Web.Optimization installed in your project. It's included by default in an MVC4 RTM app regardless if you specify the target framework as 4.5 or 4.0. This is the namespace that the bundling classes are included in, and doesn't appear to be dependent on the framework. I've deployed to a server that does not have 4.5 installed and it still works as expected for me. Just make sure the DLL gets deployed with the rest of your app.

Clothier answered 22/8, 2012 at 18:40 Comment(8)
The Microsoft documentation also seems to indicate this is a .NET 4.5 feature only. Not saying it's not running for you, but maybe you have a reference to 4.5 on your system somewhere?Stoffel
Updated my answer with some information I found regarding the namespace.Clothier
@JoeyGennari The MSDN doc page shows when it first shipped as a part of .NET. You'd need to check the history of the Nuget package to know when the team first shipped it out-of-band.Krasner
@JoeyGennari the optimization stuff requires ASP.NET 4.5 which runs on .NET 4. A little version confusion for us all there.Keijo
Why should I use Debug=true in a production server? just for having the bundles render the css paths correctly? Or am I misunderstanding your solution? I have this very problem with an MVC5 site, and I also have the nuget packages installed in the solution.Slatternly
You don't have to. The Debug flag in the web.config is just what the minification/bundling logic uses to determine if they should be applied or not. Debugging minified JS is a pain so it will not by default apply it to a site running in debug mode or when EnableOptimizations is set to false. If you don't want them all combined to one per bundle you can turn it off using the EnableOptimizations property.Clothier
When I right click on the project to deploy to Azure, if Settings -> Configuration is set to 'Release', then my css is blocked by permissions. If I set to 'Debug', my site loads correctly. ...strange.Chronister
its 2020 now and the solution still worked like knife through butter... I was struggling for quite sometime on thisBellini
N
12

Just to clarify a few things, System.Web.Optimization (aka Bundling/Minification) will work against 4.0. It is not depending on anything in 4.5, so there should be no problems there.

If script bundling is working, and its only an issue with CSS, perhaps the issue is with relative URLs?

I'd first look at the rendered page and see if you are getting references to the CSS bundle, i.e. something like:

<link href="/app/Content/css?v=oI5uNwN5NWmYrn8EXEybCI" rel="stylesheet"/>

If you are, then bundling is working, but something inside your CSS bundle is messed up. Usually this is due to relative URLs inside your CSS bundle being incorrect, i.e. if your images live under ~/Content, but you name your bundle ~/bundles/css, the browser will incorrectly look for images under ~/bundles.

Also, the default behavior is to disable bundling and minification when debug=true. So, if you do want optimizations enabled even when debug=true, you will need to force:

BundleTable.EnableOptimizations = true

Updated: With the new info that v="", that means the bundle was empty, you should verify that you are adding files to the bundle correctly, and that it found them. How are you including files to the bundle?

Nutrilite answered 24/8, 2012 at 17:56 Comment(4)
I'm not getting the number after v= in the generated link.Opportunity
This is usually an indication that your bundle isn't registered correctly. Double check that you actually are adding a Bundle with "~/app/Content/css" as the Path to BundleTables.Bundles.Nutrilite
I updated my answer, basically you need to look at what's in your bundle, its almost certainly empty, or has only empty files included.Nutrilite
My bundling/mini always worked until I've added a few more CSS to the bundle method. After that, I got this v=@#$$#%#$ story. The explanation here can be true only if there're conclusive resources identifying it. My problem persists, and nothing above (prior to this comment) works.Protozoal
Y
10

Omitting runAllManagedModulesForAllRequests="true" also worked for me. Add the following configuration in web.config:

<modules>
  <remove name="BundleModule" />
  <add name="BundleModule" type="System.Web.Optimization.BundleModule" />
</modules>

runAllManagedModulesForAllRequests will impose a performance hit on your website if not used appropriately. Check out this article.

Yard answered 23/5, 2013 at 15:50 Comment(0)
G
3

Another thing to consider is the references cannot have the same name. For example, if you have jQuery UI in the libraries directory, and bundle its JavaScript file like so:

bundles.Add(new ScriptBundle("~/libraries").Include("~/libraries/jquery-ui/jqyery-ui.js"));

and then try to bundle its CSS files like so:

bundles.Add(new StyleBundle("~/libraries").Include("~/libraries/jquery-ui/jqyery-ui.css"));
...

it will fail. They have to have unique names. So do something like ScriptBundle("~/libraries/js")... and ScriptBundle("~/libraries/css")... or whatever.

Goering answered 14/1, 2015 at 21:40 Comment(0)
L
1

As an addendum to the existing answers, none of which worked for me I found my solution HERE:

https://bundletransformer.codeplex.com/discussions/429707

The solution was to

  1. right click the .less files in visual studio
  2. Select properties
  3. Mark the Build Action as Content
  4. Redeploy

I did NOT need to remove extensionless handlers (as can be found in other solutions on the internet)

I did NOT have to add the <add name="BundleModule" type="System.Web.Optimization.BundleModule" /> web.config setting.

Hope this helps!

Loveinidleness answered 22/4, 2015 at 21:6 Comment(0)
B
1

I encountered the same issue with CSS on a live environment. I followed all of the advise here and investigated how the bundling works behind the scene. This lead me to request that the .Net cache was cleared (I didn't have access to the app servers) which caused the bundling to start working on the app servers. However, when accessing the site via a load balancer with a CDN configured, although the bundle identifier was updated in the url, the bundle contained the old CSS. Simply flushing the CDN resolved the issue.

I hope this goes some way to helping some one else who may encounter this

Bernat answered 11/11, 2015 at 12:29 Comment(0)
E
1

One of my css files had an '_' character in the file name which caused issues.

Renamed your_style.css to yourstyle.css

Evaporate answered 20/9, 2016 at 19:35 Comment(0)
S
1

I know this is an old issue, but people may still face this.

The following checks if the BundleModule exists in web.config and loaded, and sets EnableOptimizations based on its existance.

This way wether it is available or not, the css/js references will work fine. In other words:

  • If BundleModule is available, the bundeling/optimization will be enabled.

  • If BundleModule is not available, the bundeling/optimization will be disabled and automatically the full references will be used instead.

Code:

public static void RegisterBundles(BundleCollection bundles)
{
   // bundeling code here
   // ...
   // bundeling code here

   bool bundelingModuleIsAvailable = false;
   try { 
       bundelingModuleIsAvailable = HttpContext.Current.ApplicationInstance.Modules.AllKeys.Contains("BundleModule"); 
   }
   catch { }
   if (!bundelingModuleIsAvailable)
       System.Diagnostics.Debug.WriteLine("WARNING : optimization bundle is not added to Web.config!");

   BundleTable.EnableOptimizations = bundelingModuleIsAvailable && !Debug_CheckIsRunning();
   //Debug_CheckIsRunning is optional, incase you want to disable optimization when debugging yourself
   BundleTable.EnableOptimizations = true;
}

private bool Debug_CheckIsRunning()
{//Check if debug is running
    string moduleName = System.Diagnostics.Process.GetCurrentProcess().MainModule.ModuleName;
    return (moduleName.Contains("iisexpress.exe") || moduleName.Contains(".vshost") || moduleName.Contains("vstest.executionengine") || moduleName.Contains("WebDev.WebServer"));
    }
Siriasis answered 11/4, 2019 at 9:8 Comment(0)
O
0

Just for history:

Check that all mentioned less/css files in bundle have Build Action = "Content".

There is no error if some files from bundle missing on destination server.

Oppugn answered 26/11, 2014 at 7:35 Comment(0)
D
0

I had the same problem and it turned out to be a stupid mistake, the css files were not included in the project so they weren't published, make sure you view all files in the solution and add them to the project.

Deandra answered 19/12, 2014 at 1:31 Comment(0)
C
0

css names must be consistent.

Names of jqueryUI css are not "jquery.ui.XXX" in Contents/themes/base folder .

so it should be :

wrong:

            bundles.Add(new StyleBundle("~/Content/themes/base/css").Include(
                                    "~/Content/themes/base/jquery.ui.core.css",
                                    "~/Content/themes/base/jquery.ui.resizable.css",
                                    "~/Content/themes/base/jquery.ui.selectable.css",
                                    "~/Content/themes/base/jquery.ui.accordion.css",
                                    "~/Content/themes/base/jquery.ui.autocomplete.css",
                                    "~/Content/themes/base/jquery.ui.button.css",
                                    "~/Content/themes/base/jquery.ui.dialog.css",
                                    "~/Content/themes/base/jquery.ui.slider.css",
                                    "~/Content/themes/base/jquery.ui.tabs.css",
                                    "~/Content/themes/base/jquery.ui.datepicker.css",
                                    "~/Content/themes/base/jquery.ui.progressbar.css",
                                    "~/Content/themes/base/jquery.ui.theme.css"));

correct :

            bundles.Add(new StyleBundle("~/Bundles/themes/base/css").Include(
                                    "~/Content/themes/base/core.css",
                                    "~/Content/themes/base/resizable.css",
                                    "~/Content/themes/base/selectable.css",
                                    "~/Content/themes/base/accordion.css",
                                    "~/Content/themes/base/autocomplete.css",
                                    "~/Content/themes/base/button.css",
                                    "~/Content/themes/base/dialog.css",
                                    "~/Content/themes/base/slider.css",
                                    "~/Content/themes/base/tabs.css",
                                    "~/Content/themes/base/datepicker.css",
                                    "~/Content/themes/base/progressbar.css",
                                    "~/Content/themes/base/theme.css"));

I tried in MVC5 and worked successfully.

Corkwood answered 24/6, 2015 at 13:45 Comment(0)
D
0

I was facing this problem while deploying the code in Azure websites. it did worked when I deployed build from visualstudio.com and wasn't when I tried to publish the build from visual studio 2013. the main problem was CSS Minification. I totally agree with 1st response to this question. but thought of sharing solution that worked for me, may be it will help you in fixing it.

basically when we deploy through VSO it generates minification files for css, js by kicking in system.web.Optimization, but when we do publish build from VS 2013 we have to take care of the below. bundling-and-minification 1. make sure the folder structure and your bundler naming convention should be different. something like this.

bundles.Add(new StyleBundle("~/Content/materialize/mcss").Include(
                  "~/Content//materialize/css/materialize.css"));

2. add at the bottom of your bundleconfig definition

public static void RegisterBundles(BundleCollection bundles)
{
  bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
             "~/Scripts/jquery-{version}.js"));

   // Code removed for clarity.
   BundleTable.EnableOptimizations = true;
}

3. make sure to add debug false in web.config (when you start local debuging VS2013 will give you a popup saying that you need to make sure to putting it back before deploying into prod. that itself explains much.

<system.web>
  <compilation debug="true" />
  <!-- Lines removed for clarity. -->
</system.web>
Deathly answered 24/7, 2015 at 12:44 Comment(0)
B
0

With Visual Studio 2015 I found the problem was caused by referencing the .min version of a javascript file in the BundleConfig when debug=true is set in the web.config.

For example, with jquery specifying the following in BundleConfig:

bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.min.js"));

resulted in the jquery not loading correctly at all when debug=true was set in the web.config.

Referencing the un-minified version:

bundles.Add(new ScriptBundle("~/bundles/jquery").Include("~/Scripts/jquery-{version}.js"));

corrects the problem.

Setting debug=false also corrects the problem, but of course that is not exactly helpful.

It is also worth noting that while some minified javascript files loaded correctly and others did not. I ended up removing all minified javascript files in favor of VS handling minification for me.

Biannual answered 5/1, 2016 at 18:33 Comment(0)
P
0

try this:

    @System.Web.Optimization.Styles.Render("~/Content/css")
    @System.Web.Optimization.Scripts.Render("~/bundles/modernizr")

It worked to me. I'm still learning, and I've not figured it out yet why it is happening

Platitude answered 22/1, 2016 at 21:24 Comment(0)
D
0

To add useful information to the conversation, I came across 404 errors for my bundles in the deployment (it was fine in the local dev environment).

For the bundle names, I including version numbers like such:

bundles.Add(new ScriptBundle("~/bundles/jquerymobile.1.4.3").Include(
...
);

On a whim, I removed all the dots and all was working magically again:

bundles.Add(new ScriptBundle("~/bundles/jquerymobile143").Include(
...
);

Hope that helps someone save some time and frustration.

Dove answered 2/2, 2016 at 17:59 Comment(0)
R
0

You need to add this code in your shared View

 @*@Scripts.Render("~/bundles/plugins")*@
    <script src="/Content/plugins/jQuery/jQuery-2.1.4.min.js"></script>
    <!-- jQuery UI 1.11.4 -->
    <script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
    <!-- Kendo JS -->
    <script src="/Content/kendo/js/kendo.all.min.js" type="text/javascript"></script>
    <script src="/Content/kendo/js/kendo.web.min.js" type="text/javascript"></script>
    <script src="/Content/kendo/js/kendo.aspnetmvc.min.js"></script>
    <!-- Bootstrap 3.3.5 -->
    <script src="/Content/bootstrap/js/bootstrap.min.js"></script>
    <!-- Morris.js charts -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
    <script src="/Content/plugins/morris/morris.min.js"></script>
    <!-- Sparkline -->
    <script src="/Content/plugins/sparkline/jquery.sparkline.min.js"></script>
    <!-- jvectormap -->
    <script src="/Content/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
    <script src="/Content/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
    <!-- jQuery Knob Chart -->
    <script src="/Content/plugins/knob/jquery.knob.js"></script>
    <!-- daterangepicker -->
    <script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"></script>
    <script src="/Content/plugins/daterangepicker/daterangepicker.js"></script>
    <!-- datepicker -->
    <script src="/Content/plugins/datepicker/bootstrap-datepicker.js"></script>
    <!-- Bootstrap WYSIHTML5 -->
    <script src="/Content/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
    <!-- Slimscroll -->
    <script src="/Content/plugins/slimScroll/jquery.slimscroll.min.js"></script>
    <!-- FastClick -->
    <script src="/Content/plugins/fastclick/fastclick.min.js"></script>
    <!-- AdminLTE App -->
    <script src="/Content/dist/js/app.min.js"></script>
    <!-- AdminLTE for demo purposes -->
    <script src="/Content/dist/js/demo.js"></script>
    <!-- Common -->
    <script src="/Scripts/common/common.js"></script>
    <!-- Render Sections -->
    @RenderSection("scripts", required: false)
    @RenderSection("HeaderSection", required: false)
Runaway answered 6/3, 2016 at 12:25 Comment(0)
E
0

I had this issue while adding some packages from nuget and forgot to do an update

So first do an update of all packages installed in the project

Update-Package

In the Global.asax.cs add the following

BundleTable.EnableOptimizations = true;
Extol answered 21/4, 2016 at 3:19 Comment(0)
R
-2

This solved my issue. I have added these lines in _layout.cshtml

@*@Scripts.Render("~/bundles/plugins")*@
<script src="/Content/plugins/jQuery/jQuery-2.1.4.min.js"></script>
<!-- jQuery UI 1.11.4 -->
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<!-- Kendo JS -->
<script src="/Content/kendo/js/kendo.all.min.js" type="text/javascript"></script>
<script src="/Content/kendo/js/kendo.web.min.js" type="text/javascript"></script>
<script src="/Content/kendo/js/kendo.aspnetmvc.min.js"></script>
<!-- Bootstrap 3.3.5 -->
<script src="/Content/bootstrap/js/bootstrap.min.js"></script>
<!-- Morris.js charts -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="/Content/plugins/morris/morris.min.js"></script>
<!-- Sparkline -->
<script src="/Content/plugins/sparkline/jquery.sparkline.min.js"></script>
<!-- jvectormap -->
<script src="/Content/plugins/jvectormap/jquery-jvectormap-1.2.2.min.js"></script>
<script src="/Content/plugins/jvectormap/jquery-jvectormap-world-mill-en.js"></script>
<!-- jQuery Knob Chart -->
<script src="/Content/plugins/knob/jquery.knob.js"></script>
<!-- daterangepicker -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.10.2/moment.min.js"></script>
<script src="/Content/plugins/daterangepicker/daterangepicker.js"></script>
<!-- datepicker -->
<script src="/Content/plugins/datepicker/bootstrap-datepicker.js"></script>
<!-- Bootstrap WYSIHTML5 -->
<script src="/Content/plugins/bootstrap-wysihtml5/bootstrap3-wysihtml5.all.min.js"></script>
<!-- Slimscroll -->
<script src="/Content/plugins/slimScroll/jquery.slimscroll.min.js"></script>
<!-- FastClick -->
<script src="/Content/plugins/fastclick/fastclick.min.js"></script>
<!-- AdminLTE App -->
<script src="/Content/dist/js/app.min.js"></script>
<!-- AdminLTE for demo purposes -->
<script src="/Content/dist/js/demo.js"></script>
<!-- Common -->
<script src="/Scripts/common/common.js"></script>
<!-- Render Sections -->
Runaway answered 6/3, 2016 at 12:30 Comment(0)
H
-6

i had the same problem . i just convert

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

and its worked. just dont forget to convert

   @Scripts.Render("~/bundles/jquery")
    @Scripts.Render("~/bundles/bootstrap")
to 
    @Scripts.Render("/bundles/jquery")
    @Scripts.Render("/bundles/bootstrap")

have nice time

Horme answered 14/6, 2014 at 5:6 Comment(2)
you have changed nothing here.Shanghai
He have taken off the symbol "~" prefixed from the bundle name :)Antinucleon

© 2022 - 2024 — McMap. All rights reserved.