8

I have a website running perfectly fine on Chrome, Firefox, Safari etc. however, the CSS does not load in Internet explorer (any version) as well as in MS Edge browser.

The Console shows this infamous error related to MIME Type:

SEC7113: CSS was ignored due to mime type mismatch
File: application-2015-2a0565839ee60a029c49fc918e3625e9.css
SEC7113: CSS was ignored due to mime type mismatch
File: CustomCss.css
SEC7113: CSS was ignored due to mime type mismatch
File: print.css

I have checked in the code, and this is how it is in the <head>

// ASP.NET MVC code - .cshtml layout file
<link href='@Url.Content("/Content/application-2015-2a0565839ee60a029c49fc918e3625e9.css")' media="screen" rel="stylesheet" type="text/css"/>
<link href='@Url.Content("/Content/CustomCss.css")' media="screen" rel="stylesheet" type="text/css"/>
<link href='@Url.Content("/Content/2015/print.css")' media="print" rel="stylesheet" type="text/css"/>

I have checked in the IE Developer Tools, and the css indeed returned with incorrect MIME type (coming as blank) in IE instead of stylesheet or text/css as in Chrome or Firefox:

IE: enter image description here

Chrome: enter image description here

I have checked in IIS, the mime type for .css is mapped as expected: enter image description here

How can I make IE to understand the Mime type and let it load it correctly.

Any help is highly appreciated.

EDIT

As suggested, also checked the Registry value for .css in HKEY_CLASSES_ROOT and this seems ok as below: enter image description here

Also, ensured that no program is associated with CSS to open.

16
  • 2
    stackoverflow.com/questions/16473610/… Commented Dec 27, 2016 at 14:39
  • thanks; I have seen that and tried all the options mentioned there - also ensured that css is not defaulted to open with a particular program. Also, getting the same behaviour on server as well as on my local machine Commented Dec 27, 2016 at 14:41
  • Does the problem persist if you use those files in a simple HTML page? Commented Dec 27, 2016 at 17:12
  • I tried with the simple HTML page, but you guess it right, with simple HTML, the issue is not there. Commented Dec 28, 2016 at 5:31
  • stackoverflow.com/questions/27490193/… Commented Dec 30, 2016 at 12:52

4 Answers 4

1

This is because under default settings, “static content” is not installed with IIS.

To enable this on a Windows Server 2008 machine do the following

  1. Fire up Server Manager

  2. Select Web Server under Roles – notice that Static Content is not installed

enter image description here

Select Add Role Services from the right hand menu

enter image description here

Check Static content and install

i think it works for you

Sign up to request clarification or add additional context in comments.

Comments

1

It turns out that there was an HTTP Module which was the root cause of it as it turns out to be a known issue with ASP.NET, IIS and HTTP Module aas mentioned here: ASP.NET CSS file not loaded when adding HttpModule to web.config

Following this and handling in Http Module explicitly for css, fixed this issue.

Thanks for everyone for taking time out and providing your expert comments

Comments

0

Looks like you've tried everything that seems to have worked for others.

Try setting the output to the mime type through the ASP.NET framework:

Response.ContentType = "text/css";

Have you tested using a load function?

Response.ContentType = "text/css"
Response.AddHeader("Header")
Response.WriteFile("CSS File.css")
Response.End()
Response.Clear()

Comments

0

You should check these things because if IE

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">

or

type="text/css" instead of type="css/stylesheet" when importing the stylesheet.

1 Comment

I am using text/css

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.