fiberOptics
fiberOptics

Reputation: 7165

Dynamic loading of css files doesn't work in IE

Almost solution I found was using javascript/jquery while on my part it should be Views in MVC. One reference is here

So I set up my css files in this way:

@{
ViewBag.Stylesheets = new string[] {
    "global/style.css",
    "global/links.css",
    .
    .
    .
    . 40 plus more css files...
};  

And load them:

@foreach (string stylesheet in
ViewBag.Stylesheets is string[] ? ViewBag.Stylesheets : new string[] { @"style.css" })
{ 
    <link href="@Url.ContentArea("~/css/" + stylesheet)" rel="stylesheet" />
}  

All of these were inside views. I have 48 css files and I notice that IE9 loads only 37 css files. For now it is not possible to combine css codes in some number of files for certain reasons. So how can I load all of these css files in IE?

Upvotes: 0

Views: 572

Answers (2)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038730

Internet Explorer has a limit of 31 CSS files per page. This limitation has been removed in IE 10.

So you have 2 possibilities if you need to support IE <= 9:

  1. reorganize your CSS rules so that you have less than 31 files
  2. combine them (recommended)

Upvotes: 3

twodayslate
twodayslate

Reputation: 2833

The ~ is unneeded. You can just have href="/css/file.css"

Upvotes: 0

Related Questions