Resource interpreted as Stylesheet but transferred with MIME type text/html in ASP.NET IIS

后端 未结 6 1802
臣服心动
臣服心动 2020-12-08 15:16

i am having a login page when executed the page is stripped out of css.

I found out this message from from chrome debugger. I am using asp.net 2008.

6条回答
  •  [愿得一人]
    2020-12-08 15:54

    Oh dear lord! This was one of those errors that seems to come from nowhere... I was scratching my head for almost 1 hour trying to identify what was causing just 1 specific .css file to show a message very similar in Chrome's console window:

    Resource interpreted as Stylesheet but transferred with MIME type text/plain
    

    You see it's text/plain instead of text/html.

    The file in question was this one:

    https://raw.github.com/LPology/Bootstrap-IE7Fix/master/css/bootstrap-ie7fix.css

    What I did in Visual Studio 2013 Ultimate was:

    • Right-clicked the project's Content folder and selected Add Style Sheet.
    • Renamed the file to bootstrap-ie7fix.css
    • Copied the full content of the above .css file
    • Pasted the entire content inside Visual Studio and saved the file

    Referenced this new file in my Razor view in an ASP.NET MVC app in the exactly same old default fashioned accepted way:

       
    

    For any crazy/unknown reason that file would show nothing in Chrome, Firefox, Internet Explorer. What the hell is going on with this file since all other ones in the exact same /Content directory are loading just fine?

    My last try was this:

    • Navigated to the original file in the browser: https://raw.github.com/LPology/Bootstrap-IE7Fix/master/css/bootstrap-ie7fix.css
    • Clicked Chrome's File => Save Page As... menu option and overwrote the existing file in my /Content dir.
    • Tried reloading my app page and voila... this mysterious .css file finally got loaded.

    I guess Visual Studio scrambled the encoding of that file initially or something like that!

提交回复
热议问题