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

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"/>

6 thoughts on “MVC Bundle Not Working with Release Configuration (Debug is False)”

  1. 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!!

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

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