Style bundling not working after IIS deployment (MVC 4)
I think you've got a name collision here. ASP.NET MVC will create a file on http://example.org/Content/helloWorldCss after minification and you already have a folder with the same path. Can you try it again after renaming your bundle?
BundleConfig.cs:
bundles.Add(new StyleBundle("~/Content/helloWorld").Include("~/Content/helloWorldCss/helloWorldStyle.css"));
_Layout.cshtml:
@Styles.Render("~/Content/helloWorld")
Why is my CSS bundling not working with a bin deployed MVC4 app?
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.
Bundled css not displaying after deploy ... ASP.NET MVC4
The bundle name is the same as the folder name on the filesystem,
Change your bundle to
bundles.Add(
new StyleBundle("~/Content/bootstrapBundle").Include(
"~/Content/bootstrap/bootstrap-responsive.css",
"~/Content/bootstrap/bootstrap-editable.css",
"~/Content/bootstrap/FileUpload.css"));
i.e. so the name of the bundle is NOT the name of a folder or file
Asp.Net MVC Style Bundles don't Render
Finally I find out that the problem was because that I've forgotten to include the style files in the project before I publish it.
so I've included them and now it works like a charm.
CSS Not Working After Published
Solved , just add
BundleTable.EnableOptimizations = false;
in BoundalConfig
Related Topics
Prevent Property from Being Serialized in Web API
How Does Wcf Deserialization Instantiate Objects Without Calling a Constructor
How to Reference Embedded Images from CSS
How to Write an Apple Push Notification Provider in C#
Seeking Clarification on Apparent Contradictions Regarding Weakly Typed Languages
Closing Excel Application Process in C# After Data Access
Convert Variable to Type Only Known at Run-Time
Serialization of Entity Framework Objects with One to Many Relationship
Use the Long Reserved Word as a Variable Name in C#
Why Doesn't Include Have Any Effect
How to Get First Record in Each Group Using Linq
How to Verify Text Is Bold Using Selenium on an Angular Website with C#
A Method for Making Http Requests on Unity iOS
How to Call (Iron)Python Code from a C# App
How to Pass Constructor Parameters to Unity's Resolve() Method