1

I am working c# MVC 4 web application. In that, I have written CSP rules in my web config file as below.

CSP in web.cofnig :

<add name="Content-Security-Policy"
         value="default-src 'self'; connect-src *; font-src *; frame-src *; img-src * data:; media-src *; object-src *; script-src * 'unsafe-inline' 'unsafe-eval'; style-src * 'unsafe-inline';"/>

After adding that rules it is not working and throwing below error

Refused to apply style from '<URL>' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

Dashboard:1 Refused to apply style from 'https://localhost:8443/scss/icons/font-awesome/css/font-awesome.min.css' because its MIME type ('text/html') is not a supported stylesheet MIME type, and strict MIME checking is enabled.

CSS : (load from CSS as per mentioned below code)

@import url(../scss/icons/font-awesome/css/font-awesome.min.css);
@import url(../scss/icons/simple-line-icons/css/simple-line-icons.css);
@import url(../scss/icons/weather-icons/css/weather-icons.min.css);
Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Hkachhia
  • 4,463
  • 6
  • 41
  • 76
  • Maybe you can check this [one](https://stackoverflow.com/questions/6089070/resource-interpreted-as-stylesheet-but-transferred-with-mime-type-text-html-in-a#:~:text=The%20correct%20MIME%20type%20for,HTTP%20sniffer%20such%20as%20fiddler.) – Thinh Tran Jul 15 '20 at 09:28
  • I have check mime type in IIS and it is correct and I have also checked the header value of that file request in that it is sending type text/CSS but in response, I am getting text/html – Hkachhia Jul 15 '20 at 09:36
  • Have you checked and ensured "Static Content" in IIS Windows Features is enabled? – Thinh Tran Jul 15 '20 at 09:39
  • yes it is enable – Hkachhia Jul 15 '20 at 09:45
  • All other CSS are loading except import CSS from the CSS – Hkachhia Jul 15 '20 at 09:47

0 Answers0