MVC Bundle Not Working with Release Configuration (Debug is False)

08 Feb

I encountered problem with Scripts and Styles bundle when deploying ASP.Net MVC 4 application to Windows Azure. The site loaded without CSS and JavaScript and developer tools show bunch of URL bundles returning 404 errors.

Solution was to add the following code to web.config

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

When deploying with Release configuration manager, <compilation> debug is set to false and MVC minify all CSS and JavaScript files.

If run with debug="true" output is 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 run with debug="false", output is the following instead:

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

Posted by on February 8, 2013 in General


Tags: , , , ,

6 responses to “MVC Bundle Not Working with Release Configuration (Debug is False)

  1. dotnetanswers

    February 10, 2014 at 9:36 pm

    thank you, thank you, thank you

  2. VickyLund99

    July 1, 2014 at 3:54 am

    Hi stack247,
    I have the same issue and tried your solution but still it din’t work.
    Is there anything else to take care of ?
    Thanks in advance!!

  3. xgrinderx

    March 8, 2016 at 7:55 pm

    Over 3 years later and this post just saved my bacon on a deployment. Thanks!

  4. Smart Pioneer

    January 15, 2017 at 5:53 am

    Inside RegisterBundles function in BundleConfig class just put:
    BundleTable.EnableOptimizations = false;

  5. saroj

    July 10, 2017 at 4:52 am

    not working on Azure server


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: