SEC7113: CSS was ignored due to mime type mismatch - ASP.NET MVC

In my ASP.NET MVC application, I add CSS and JavaScript files as follows:

@Script.AddCss("~/Content/css/style2.css", siteWide: true) @Script.AddCss("~/Content/css/tipsy.css", siteWide: true) @Script.AddJavaScript(localPath: "~/Content/js/modernizr-2.5.3.js", siteWide: true) @Script.AddJavaScript(localPath: "~/Content/js/jquery/jquery.datatables.js", siteWide: true) 

And the result is as follows:

 @Script.OutputCss() 

And almost the same for JavaScript:

 @Script.OutputJavaScript() 

The template engine then merges all the files into AXD files and places them in the page source, preserving the content type.

This works fine in all browsers, but not in IE9. Sometimes style sheets do not load, and the following error message appears in the console:

 SEC7113: CSS was ignored due to mime type mismatch scripts.axd?type=Stylesheet&hash=74A0F67DE9D74AFCDAE1AA539EA11099 

In addition, when viewing the Network tab, AXD files are downloaded twice - 2 AXD files for CSS and 2 AXD files for JavaScript. One of the files weighs 0 bytes. This does not always happen, but only sometimes, too often.

Can someone help me with advice on where the problem is?

Thanks in advance.

+1
asp.net-mvc asp.net-mvc-3 razor
source share
2 answers

Due to the MIME type mismatch, css was ignored at points 9 and 10. The MIME type can be correct with a utility called FIle TypesMan . Free software created by NirSoft. It turned out that the MIME type .css was changed to text / plain, not allowing me to give away my styles. using FileTypesMan to change it to text / css, fixed the problem.

  • Download FileTypesMan from NirSoft. Use the links at the bottom of the page to select the correct version for your operating system (there are different versions for 32-bit, 64-bit, and Windows 98 / ME).
  • Unzip the files to a local folder and double-click FileTypesMan.exe.
  • When FileTypesMan finishes listing all file types, scroll down the page in the top bar to find .css.
  • Double click to change settings.
  • Change the value in text / css in the MIME Type field in the dialog box that opens.
  • Click OK. Work is done. Now IE 10 should behave (well, at least as far as styling is concerned).
+2
source share

In IE9, you need the MIME text / CSS type for cross-domain style sheets when the source page is not in a trusted zone. When occurring in a trusted zone, it should work without text / CSS MIME, which is probably due to the fact that you sometimes encounter your problem.

Therefore, make sure the ContentType declaration is present in your directive on the page:

 <%@ Page Language="C#" ContentType="text/css" %> 

hope this was a problem.

-2
source share

All Articles