Associated css not showing after deployment ... ASP.NET MVC4

When deploying my MVC application, the .NET 4.5 framework integrates and reduces my CSS. However, the resulting file is empty, so CSS rules are not applied. In Chrome, the warning Resource interpreted as Stylesheet but transferred with MIME type text/plain appears. In IE9, I get a CSS was ignored due to mime type mismatch warning that CSS was ignored due to mime type mismatch .

This is what is in my bundleconfig

 bundles.Add( new StyleBundle("~/Content/bootstrap").Include( "~/Content/bootstrap/bootstrap-responsive.css", "~/Content/bootstrap/bootstrap-editable.css", "~/Content/bootstrap/FileUpload.css")); 

Here is my layout:

 <head> <meta charset="utf-8" /> <meta http-equiv="x-ua-compatible" content="IE=Edge" /> <title>@ViewBag.Title</title> <link href="~/favicon.ico" rel="shortcut icon" type="image/x-icon" /> <meta name="viewport" content="width=device-width" /> <link href="@ViewBag.StyleUrl" rel="stylesheet" type="text/css" /> @Styles.Render("~/Content/bootstrap") <script src="~/scripts/libs/modernizr/modernizr-2.5.3.js" type="text/javascript"></script> </head> 

An additional stylesheet is for a dynamically loaded stylesheet based on the configuration in our Admin tool.

When I run it locally, or if I set debug = "true", then I get my individual files and everything looks as it should. If I rigidly bind them to my layout page, they appear in order. I checked IIS and looked at the correct MIME type for CSS (which makes sense, given that hardcoded values ​​work). I also checked to make sure that the "Static Content" role service is installed, since I encountered it in my googling as well.

Any thoughts?

+7
source share
3 answers

The name of the package matches the name of the folder in the file system,

Change your package to

 bundles.Add( new StyleBundle("~/Content/bootstrapBundle").Include( "~/Content/bootstrap/bootstrap-responsive.css", "~/Content/bootstrap/bootstrap-editable.css", "~/Content/bootstrap/FileUpload.css")); 

i.e. therefore the package name is not the name of the folder or file

+22
source

There was the same problem. My solution was an invalid package name (it consisted of "_" or "."). The name should be plain text:

 bundles.Add( new StyleBundle("~/Content/bootstrap_Bundle").Include( "~/Content/bootstrap/bootstrap-responsive.css", "~/Content/bootstrap/bootstrap-editable.css", "~/Content/bootstrap/FileUpload.css")); 

should have been:

 bundles.Add( new StyleBundle("~/Content/bootstrapBundle").Include( "~/Content/bootstrap/bootstrap-responsive.css", "~/Content/bootstrap/bootstrap-editable.css", "~/Content/bootstrap/FileUpload.css")); 
+1
source

If you use a product like Point Defender, it can also give you this error condition. When you contact, if the cache byte parameter contains double hyphens, then a product such as dot protector sees SQL injection as a possible attack and ultimately interferes with the request / response.

One way around this (assuming you cannot disable this software) is to simply add something to the css source file, for example .dotdefenderbuster {} .

I need to check if the binding algorithm is updated to influence the cache key.

For example: http://www.foo.com/MyApp/Content/themes/MyApp/css?v=J9DBkvB7JWRo80eUukDOe3--6DAtA1

0
source

All Articles